:root {
  --bg: #070a12;
  --bg-2: #101729;
  --panel: #111a2e;
  --panel-2: #18233f;
  --text: #e6edf8;
  --muted: #9cb1d4;
  --primary: #4f8cff;
  --danger: #ff5f6d;
  --success: #38c793;
  --border: #283655;
  --layout-max: 1420px;
  --layout-pad: 28px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: "Segoe UI", "Inter", sans-serif;
  background:
    radial-gradient(1000px 500px at 20% -20%, #1f2d58 0%, transparent 70%),
    radial-gradient(1200px 700px at 120% -10%, #12284f 0%, transparent 60%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(8px);
  background: rgba(7, 10, 18, 0.75);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  width: 100%;
  max-width: var(--layout-max);
  padding: 0 var(--layout-pad);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
}

.brand {
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
}

.brand-logo {
  display: block;
  height: 44px;
  width: auto;
  max-width: none;
}

.nav {
  display: flex;
  gap: 12px;
  align-items: center;
}

.locale-form {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.locale-label {
  font-size: 12px;
  color: var(--muted);
}

.locale-form select {
  background: #0b1222;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 8px;
}

.nav a {
  color: var(--muted);
  text-decoration: none;
}

.container {
  width: 100%;
  max-width: var(--layout-max);
  padding: 0 var(--layout-pad);
  margin: 24px auto 60px;
  display: grid;
  gap: 16px;
}

.panel {
  background: linear-gradient(160deg, rgba(24, 35, 63, 0.92), rgba(17, 26, 46, 0.96));
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
}

.panel-muted {
  opacity: 0.92;
}

h1, h2 {
  font-weight: 200;
  margin-top: 0;
  margin-bottom: 2px;
}

p, li, label, input, textarea, button, td, th {
  font-size: 15px;
}

.actions {
  margin-top: 12px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn-primary,
.btn-secondary,
.btn-ghost,
button {
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:disabled,
button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}

.btn-danger {
  background: rgba(120, 30, 40, 0.85);
  color: #ffe8eb;
  border: 1px solid rgba(255, 95, 109, 0.45);
}

.alert {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  opacity: 1;
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.alert-hide {
  opacity: 0;
  transform: translateY(-6px);
}

.alert-error {
  background: rgba(255, 95, 109, 0.12);
  border-color: rgba(255, 95, 109, 0.35);
}

.alert-success {
  background: rgba(56, 199, 147, 0.12);
  border-color: rgba(56, 199, 147, 0.35);
}

.form-grid {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
}

.field-hint {
  min-height: 16px;
  font-size: 12px;
  color: var(--muted);
}

fieldset {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
}

legend {
  color: var(--muted);
  padding: 0 6px;
}

.group-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

.inline-check {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-start;
  width: fit-content;
}

.inline-check input {
  margin: 0;
}

.group-app-extra {
  display: grid;
  gap: 12px;
}

.group-app-toggle {
  justify-self: start;
}

.group-app-toggle.is-active {
  background: var(--primary);
  border-color: transparent;
  color: #fff;
}

.manage-inline-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.short-select {
  width: min(240px, 100%);
}

.user-quota-form {
  margin-top: 6px;
}

.user-quota-label {
  gap: 6px;
}

.user-admin-actions {
  justify-content: flex-end;
  margin-top: 8px;
  align-items: center;
}

.manage-user-edit-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.manage-user-edit-grid label {
  margin: 0;
}

.invite-form {
  margin-bottom: 16px;
}

.group-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
}

.group-pill {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 10px;
  align-items: start;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(11, 18, 34, 0.65);
}

.group-pill input {
  margin-top: 3px;
  width: 16px;
  height: 16px;
}

.group-pill-title {
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
}

.group-pill-sub {
  grid-column: 2;
  color: var(--muted);
  font-size: 12px;
}

.invite-table {
  min-width: 1240px;
}

.invite-table th {
  white-space: nowrap;
}

.invite-table td {
  white-space: normal;
}

.group-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.group-chip {
  display: inline-block;
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #0d1730;
  color: var(--text);
  font-size: 12px;
}

.desktop-only {
  display: block;
}

.mobile-only {
  display: none;
}

.manage-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(12, 19, 35, 0.75);
  margin-bottom: 10px;
  overflow: hidden;
}

.manage-card summary {
  list-style: none;
  cursor: pointer;
  display: grid;
  gap: 4px;
  padding: 10px 12px;
}

.manage-card summary::-webkit-details-marker {
  display: none;
}

.manage-card-title {
  font-weight: 700;
}

.manage-card-sub {
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.manage-card-body {
  padding: 0 12px 12px;
  border-top: 1px solid var(--border);
}

.manage-card-body p {
  margin: 10px 0 0;
}

.manage-card-body .form-grid + .form-grid {
  margin-top: 12px;
}

.manage-page {
  display: grid;
  gap: 16px;
}

.manage-subnav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.manage-subnav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(11, 18, 34, 0.75);
  color: var(--muted);
  text-decoration: none;
}

.manage-subnav-link.is-active {
  background: var(--primary);
  color: #fff;
  border-color: transparent;
}

.manage-card-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
}

.stoat-admin-grid {
  grid-template-columns: 1fr;
}

.manage-select-grid .manage-card {
  margin-bottom: 0;
}

.manage-select-card .manage-card-body {
  display: none;
}

.manage-select-card.is-active {
  border-color: rgba(79, 140, 255, 0.55);
  box-shadow: 0 0 0 1px rgba(79, 140, 255, 0.25) inset;
}

.manage-detail-view {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(12, 19, 35, 0.55);
  padding: 12px;
  margin-bottom: 12px;
}

.manage-detail-view[hidden] {
  display: none;
}

.manage-detail-hint {
  margin: 0;
  color: var(--muted);
}

.manage-detail-title {
  margin: 2px 0 8px;
  font-size: 22px;
  line-height: 1.2;
}

.detail-dn {
  margin: 0 0 14px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(11, 18, 34, 0.5);
}

.group-create-card {
  margin-bottom: 14px;
}

.public-avatar-list {
  margin-top: 14px;
}

.admin-log-table {
  width: 100%;
  table-layout: auto;
}

.admin-log-table th,
.admin-log-table td {
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
  vertical-align: top;
}

.admin-log-details {
  min-width: 300px;
}

.admin-log-target {
  min-width: 220px;
}

.admin-log-ip {
  min-width: 120px;
  white-space: nowrap;
}

.admin-log-detail-list {
  display: grid;
  gap: 4px;
}

.admin-log-detail-item {
  line-height: 1.3;
}

.page-home .container {
  max-width: 100%;
  margin: 0;
  padding: 0;
  min-height: 100vh;
}

.page-home .container > .alert {
  width: min(560px, calc(100% - 24px));
  margin: 14px auto 0;
}

.landing-wrap {
  position: relative;
  min-height: calc(100vh - 80px);
  display: grid;
  place-items: center;
  padding: 28px 16px 54px;
}

.landing-wrap.has-bg::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  background-image:
    linear-gradient(rgba(5, 8, 15, 0.72), rgba(5, 8, 15, 0.72)),
    var(--landing-bg-image);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.landing-wrap.has-bg::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background: radial-gradient(1200px 650px at 50% -10%, rgba(27, 48, 93, 0.45) 0%, transparent 65%);
}

.landing-card {
  width: min(560px, 100%);
  border: 1px solid #26365b;
  border-radius: 24px;
  background: linear-gradient(160deg, rgba(10, 14, 26, 0.95), rgba(8, 12, 22, 0.96));
  padding: 28px 26px 22px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  align-items: center;
  justify-items: center;
  text-align: center;
  box-shadow: 0 10px 28px rgba(3, 7, 16, 0.45);
}

.landing-right {
  display: grid;
  align-content: center;
  justify-items: center;
  width: 100%;
  max-width: none;
}

.landing-logo {
  height: 150px;
  width: auto;
  margin-bottom: 0;
}

.landing-logo-fallback {
  font-size: 42px;
  font-weight: 700;
  margin-bottom: 0;
}

.landing-title {
  margin: 0;
  font-size: clamp(25px, 4.2vw, 34px);
  line-height: 1.15;
}

.landing-right {
  width: min(460px, 100%);
  border: 1px solid #2b3a60;
  border-radius: 16px;
  background: rgba(12, 19, 35, 0.72);
  padding: 20px 18px;
  margin-top: 120px;
  margin-bottom: 60px;
  gap: 10px;
  text-align: center;
}

.landing-info {
  margin: 0;
  color: #c5d4f4;
  font-size: 16px;
  line-height: 1.4;
  text-align: center;
}

.landing-actions {
  margin-top: 14px;
  justify-content: center;
}

.landing-nav {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: center;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.landing-nav a {
  text-decoration: none;
}

.landing-nav form {
  margin: 0;
}

.nav-btn {
  min-width: 132px;
}

.landing-profile-box {
  width: min(460px, 100%);
  border: 1px solid #2b3a60;
  border-radius: 16px;
  background: rgba(12, 19, 35, 0.72);
  padding: 18px 16px;
  display: grid;
  grid-template-columns: minmax(120px, 40%) 1px 1fr;
  align-items: center;
  gap: 12px;
  text-align: center;
}

.landing-profile-avatar {
  width: 120px;
  height: 120px;
  justify-self: center;
  border-radius: 999px;
  overflow: hidden;
  background: #0b1222;
  display: grid;
  place-items: center;
  color: #d7e5ff;
  font-weight: 700;
  font-size: 38px;
}

.landing-profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.landing-profile-sep {
  width: 1px;
  height: 78%;
  background: var(--border);
  justify-self: center;
  align-self: center;
  border-radius: 1px;
}

.landing-profile-name {
  font-size: 24px;
  font-weight: 700;
  line-height: 1.1;
}

.landing-profile-mail {
  color: var(--muted);
  font-size: 14px;
  overflow-wrap: anywhere;
}

.landing-profile-text {
  min-height: 150px;
  display: grid;
  place-content: center;
  gap: 8px;
  justify-items: center;
  text-align: center;
}

.landing-apps-box {
  width: min(460px, 100%);
  border: 1px solid #2b3a60;
  border-radius: 16px;
  background: rgba(12, 19, 35, 0.72);
  padding: 18px 16px;
  text-align: center;
}

.landing-apps-empty {
  margin: 0;
  color: var(--muted);
}

.landing-apps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  justify-items: center;
}

.landing-app-card {
  width: 100%;
  border: 0;
  border-radius: 12px;
  background: #0b1222;
  color: var(--text);
  text-decoration: none;
  display: grid;
  gap: 0;
  padding: 10px;
  justify-items: center;
}

.landing-app-card:hover {
  box-shadow: 0 0 0 1px rgba(79, 140, 255, 0.45) inset;
}

.landing-app-logo {
  width: 82px;
  height: 82px;
  border-radius: 16px;
  overflow: hidden;
  background: #15244a;
  display: grid;
  place-items: center;
  font-weight: 700;
}

.landing-app-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.landing-footer {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.landing-page-footer {
  position: fixed;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  opacity: 0.95;
  z-index: 1;
}

.hcaptcha-wrap {
  display: flex;
  justify-content: flex-start;
  width: 100%;
}

.avatar-current {
  display: grid;
  gap: 10px;
}

.avatar-current-frame {
  width: 128px;
  height: 128px;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #0b1222;
}

.avatar-current-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.avatar-placeholder {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 13px;
}

.avatar-editor {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: rgba(11, 18, 34, 0.7);
}

.account-avatar-upload {
  width: min(100%, 640px);
}

.avatar-crop-stage {
  width: min(320px, 100%);
  aspect-ratio: 1 / 1;
  position: relative;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  touch-action: none;
}

.account-profile-form {
  display: grid;
  gap: 14px;
}

.account-profile-form label {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 8px 14px;
  align-items: center;
  margin: 0;
  text-align: right;
}

.account-profile-form label input,
.account-profile-form label textarea,
.account-profile-form label select {
  grid-column: 2;
  text-align: left;
}

.account-profile-form label .field-hint {
  grid-column: 2;
}

.account-static-row {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 8px 14px;
  align-items: center;
}

.account-static-label {
  color: var(--muted);
  text-align: right;
}

.account-static-value {
  color: var(--text);
  text-align: left;
  overflow-wrap: anywhere;
}

.avatar-crop-stage canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
}

.avatar-crop-stage canvas:active {
  cursor: grabbing;
}

.avatar-circle-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.avatar-circle-overlay::before {
  content: "";
  position: absolute;
  inset: 0;
  border: 2px solid rgba(255, 255, 255, 0.78);
  border-radius: 50%;
  box-shadow: 0 0 0 200vmax rgba(3, 8, 15, 0.46);
}

.avatar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 10px;
  margin-top: 2px;
}

.avatar-item {
  position: relative;
}

.avatar-tile-form {
  margin: 0;
}

.avatar-tile {
  width: 100%;
  aspect-ratio: 1 / 1;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: #0b1222;
  padding: 0;
  display: block;
}

button.avatar-tile {
  cursor: pointer;
}

.avatar-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.avatar-tile.readonly {
  pointer-events: none;
}

.avatar-delete-form {
  position: absolute;
  top: 4px;
  right: 4px;
  margin: 0;
  z-index: 2;
}

.avatar-delete-btn,
.avatar-delete-action {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(8, 13, 25, 0.92);
  color: #ffd6d9;
  display: inline-grid;
  place-items: center;
  padding: 0;
  cursor: pointer;
  line-height: 1;
}

.avatar-delete-btn:hover,
.avatar-delete-action:hover {
  border-color: rgba(255, 95, 109, 0.55);
  color: #fff0f2;
  background: rgba(120, 30, 40, 0.82);
}

input, textarea {
  width: 100%;
  background: #0b1222;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}

select {
  width: 100%;
  background: #0b1222;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}

input:disabled {
  opacity: 0.7;
}

.table-wrap {
  overflow-x: auto;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  text-align: left;
  border-bottom: 1px solid var(--border);
  padding: 10px 8px;
  vertical-align: top;
  word-break: break-word;
}

.mono, code {
  font-family: "Consolas", "Courier New", monospace;
  font-size: 13px;
  overflow-wrap: anywhere;
}

@media (max-width: 720px) {
  .topbar-inner,
  .container {
    padding: 0 14px;
  }
  .topbar-inner {
    align-items: flex-start;
    flex-direction: column;
    padding-top: 10px;
    padding-bottom: 10px;
    gap: 8px;
  }
  .nav {
    width: 100%;
    justify-content: space-between;
  }

  .landing-wrap {
    min-height: calc(100vh - 20px);
    padding: 14px 12px;
  }

  .landing-card {
    gap: 16px;
    padding: 18px 16px;
    border-radius: 20px;
  }

  .landing-title {
    font-size: clamp(24px, 7.2vw, 32px);
  }

  .landing-right {
    padding: 16px;
    margin-top: 10px;
    margin-bottom: 60px;
  }

  .landing-right,
  .landing-profile-box,
  .landing-apps-box {
    width: 100%;
  }

  .landing-profile-avatar {
    width: 120px;
    height: 120px;
    font-size: 32px;
  }

  .landing-profile-name {
    font-size: 21px;
  }

  .landing-profile-box {
    grid-template-columns: minmax(120px, 40%) 1px 1fr;
  }

  .landing-profile-text {
    min-height: 120px;
  }

  .landing-nav {
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 12px;
  }

  .landing-page-footer {
    bottom: 10px;
    font-size: 12px;
  }
}

@media (min-width: 721px) and (max-width: 1080px) {
  :root {
    --layout-max: 100%;
    --layout-pad: 16px;
  }

  .invite-table {
    min-width: 980px;
  }
}

@media (max-width: 980px) {
  .page-manage .group-picker {
    grid-template-columns: 1fr;
  }

  .page-manage .invite-table {
    min-width: auto;
  }

  .page-manage h1,
  .page-manage h2 {
    overflow-wrap: anywhere;
  }
}

@media (max-width: 780px) {
  .page-manage .panel {
    padding: 14px;
  }

  .page-manage .desktop-only {
    display: none;
  }

  .page-manage .mobile-only {
    display: block;
  }
}

@media (max-width: 900px) {
  .account-profile-form label,
  .account-static-row {
    grid-template-columns: 1fr;
    text-align: left;
  }

  .account-profile-form label input,
  .account-profile-form label textarea,
  .account-profile-form label select,
  .account-profile-form label .field-hint {
    grid-column: 1;
  }

  .account-static-label {
    text-align: left;
  }

  .account-avatar-upload {
    width: 100%;
  }
}
