@import url("fonts.css");

:root {
  color-scheme: dark;
  --bg: #071126;
  --bg-deep: #030817;
  --surface: #101d36;
  --surface-raised: #152440;
  --surface-soft: #0c1830;
  --line: rgba(169, 201, 255, .18);
  --line-strong: rgba(169, 201, 255, .34);
  --text: #f5f7fb;
  --muted: #aab7d0;
  --accent: #72a9ff;
  --accent-strong: #3e86f4;
  --success: #52d18c;
  --danger: #ff7a85;
  --radius: 20px;
  --shadow: 0 24px 70px rgba(0, 0, 0, .3);
  --font: "LHT Interface", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 96px; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at 82% 0%, #142c58 0, transparent 34%), var(--bg-deep); color: var(--text); font-family: var(--font); font-optical-sizing: auto; font-kerning: normal; font-synthesis: none; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
button, input, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
:focus-visible { outline: 3px solid #9fc5ff; outline-offset: 3px; }

.button { min-height: 44px; padding: 0 18px; border: 1px solid transparent; border-radius: 14px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; color: var(--text); text-decoration: none; font-weight: 650; cursor: pointer; transition: transform 140ms ease, background 140ms ease, border-color 140ms ease; }
.button:active { transform: scale(.98); }
.button.primary { background: var(--accent-strong); box-shadow: 0 10px 28px rgba(62, 134, 244, .26); }
.button.primary:hover { background: #5597ff; }
.button.disabled { opacity: .48; cursor: not-allowed; box-shadow: none; }
.button.secondary { background: #1c2d4c; border-color: var(--line); }
.button.secondary:hover, .button.quiet:hover { background: #243858; border-color: var(--line-strong); }
.button.quiet { background: rgba(19, 35, 64, .72); border-color: var(--line); }

.auth-shell { min-height: 100vh; padding: 32px 20px; display: grid; place-items: center; background: radial-gradient(circle at 20% 15%, rgba(64, 126, 235, .26), transparent 36%), radial-gradient(circle at 80% 82%, rgba(76, 105, 181, .18), transparent 38%); }
.auth-card { width: min(460px, 100%); padding: 34px; border: 1px solid var(--line); border-radius: 30px; background: rgba(10, 23, 48, .78); box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, .1); backdrop-filter: blur(28px) saturate(1.35); }
.auth-mark, .brand-mark { display: grid; place-items: center; color: #08142b; background: linear-gradient(145deg, #d9e8ff, #75aaff); font-weight: 850; }
.auth-mark { width: 52px; height: 52px; margin-bottom: 26px; border-radius: 16px; font-size: 22px; box-shadow: 0 12px 34px rgba(91, 150, 255, .28); }
.eyebrow { margin: 0 0 10px; color: var(--accent); font-size: 12px; font-weight: 750; letter-spacing: .13em; }
.auth-card h1 { margin: 0; font-size: clamp(30px, 7vw, 42px); line-height: 1.05; letter-spacing: -.04em; }
.auth-copy { margin: 16px 0 26px; color: var(--muted); line-height: 1.55; }
.auth-form { display: grid; gap: 16px; }
.auth-form .button { margin-top: 4px; width: 100%; }
.discord-button { width: 100%; background: #5865f2 !important; }
.discord-button:hover { background: #6975f7 !important; }
.discord-button svg { width: 22px; height: 22px; fill: currentColor; }
.privacy-hint { margin: 15px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.output-link { display: block; margin-top: 24px; color: var(--muted); text-align: center; text-decoration: none; font-size: 14px; }
.output-link:hover { color: var(--text); }
.field-hint { margin: -6px 0 0; color: var(--muted); font-size: 12px; line-height: 1.4; }

.topbar { position: sticky; top: 0; z-index: 30; height: 76px; padding: 0 max(22px, calc((100vw - 1480px) / 2)); display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line); background: rgba(5, 12, 27, .74); backdrop-filter: blur(24px) saturate(1.35); }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 38px; height: 38px; border-radius: 12px; }
.brand b, .brand span { display: block; }
.brand b { font-size: 15px; }
.brand span { margin-top: 2px; color: var(--muted); font-size: 12px; }
.top-actions, .top-actions form { display: flex; gap: 10px; margin: 0; }
.admin-chip { min-height: 44px; padding: 5px 12px 5px 5px; display: flex; align-items: center; gap: 9px; border: 1px solid var(--line); border-radius: 14px; background: rgba(19, 35, 64, .72); }
.admin-chip img, .admin-chip > span { width: 32px; height: 32px; display: grid; place-items: center; object-fit: cover; border-radius: 50%; background: linear-gradient(145deg, #649fff, #26489f); font-size: 12px; font-weight: 750; }
.admin-chip b { max-width: 145px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }

.dashboard { width: min(1480px, 100%); margin: 0 auto; padding: 44px 24px 130px; display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 48px; }
.sidebar { position: sticky; top: 112px; align-self: start; display: grid; gap: 4px; }
.sidebar a { min-height: 42px; padding: 0 13px; display: flex; align-items: center; border-radius: 12px; color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 600; }
.sidebar a:hover { color: var(--text); background: var(--surface-soft); }
.editor { min-width: 0; }
.page-intro { max-width: 760px; margin-bottom: 58px; }
.page-intro h1 { margin: 0; font-size: clamp(38px, 6vw, 68px); line-height: .98; letter-spacing: -.055em; }
.page-intro > p:last-child { margin: 20px 0 0; color: var(--muted); font-size: 16px; line-height: 1.55; }
.page-intro strong { color: var(--text); }

.settings-section { margin-top: 64px; }
.section-heading { margin-bottom: 18px; display: flex; align-items: end; justify-content: space-between; gap: 30px; }
.section-heading > div { display: flex; align-items: baseline; gap: 12px; }
.section-heading h2 { margin: 0; font-size: 25px; letter-spacing: -.035em; }
.section-heading > p { max-width: 500px; margin: 0; color: var(--muted); text-align: right; font-size: 13px; line-height: 1.45; }
.step { margin: 0; color: var(--accent); font-size: 12px; font-variant-numeric: tabular-nums; font-weight: 750; }
.surface { padding: 24px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-soft); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .035); }
.fields-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.field { min-width: 0; display: grid; gap: 8px; }
.field.wide { grid-column: 1 / -1; }
.field > span, .auth-form label > span { display: flex; justify-content: space-between; gap: 12px; color: #d9e2f2; font-size: 13px; font-weight: 650; }
.field small { color: var(--muted); font-weight: 450; }
.field input:not([type="range"]), .field textarea, .auth-form input { width: 100%; min-height: 46px; padding: 11px 13px; border: 1px solid var(--line); border-radius: 12px; color: var(--text); background: var(--surface-raised); outline: none; transition: border-color 130ms ease, box-shadow 130ms ease; }
.field textarea { resize: vertical; line-height: 1.5; }
.field input:not([type="range"]):focus, .field textarea:focus, .auth-form input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(114, 169, 255, .12); }
.field-pair { display: grid; grid-template-columns: minmax(140px, .45fr) minmax(0, 1fr); gap: 14px; }

.notice { margin: 0 0 22px; padding: 13px 15px; border: 1px solid; border-radius: 13px; font-size: 14px; line-height: 1.4; }
.notice.success { color: #bff2d4; border-color: rgba(82, 209, 140, .35); background: rgba(36, 129, 79, .16); }
.notice.error { color: #ffd0d4; border-color: rgba(255, 122, 133, .36); background: rgba(155, 40, 50, .18); }
.discord-state { margin-bottom: 18px; padding: 11px 13px; display: flex; align-items: center; gap: 9px; border-radius: 12px; color: var(--muted); background: var(--surface-raised); font-size: 13px; }
.state-dot, .save-dot { width: 8px; height: 8px; border-radius: 50%; background: #7d899f; box-shadow: 0 0 0 4px rgba(125, 137, 159, .1); }
.discord-state.available .state-dot { background: var(--success); box-shadow: 0 0 0 4px rgba(82, 209, 140, .1); }
.team-editor { display: grid; gap: 10px; margin-bottom: 16px; }
.team-row { padding: 14px; display: grid; grid-template-columns: 48px minmax(140px, 1fr) minmax(140px, .9fr) minmax(140px, .9fr) minmax(170px, .85fr) auto; align-items: end; gap: 12px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface-raised); }
.member-avatar { width: 44px; height: 44px; align-self: end; display: grid; place-items: center; overflow: hidden; border-radius: 50%; color: white; background: linear-gradient(145deg, #649fff, #26489f); font-weight: 750; }
.member-avatar img { width: 100%; height: 100%; object-fit: cover; }
.discord-feedback { grid-column: 2 / -2; min-height: 16px; margin: -2px 0 0; color: var(--muted); font-size: 12px; line-height: 1.35; }
.discord-feedback[data-state="success"] { color: #9ce7bd; }
.discord-feedback[data-state="error"] { color: #ffafb7; }
.discord-feedback[data-state="loading"] { color: var(--accent); }
.team-row-actions { align-self: end; display: flex; gap: 3px; }
.icon-button { width: 38px; height: 38px; border: 1px solid transparent; border-radius: 11px; color: var(--muted); background: transparent; font-size: 22px; cursor: pointer; }
.icon-button:disabled { opacity: .28; cursor: default; }
.move-member:not(:disabled):hover { color: #cfe1ff; border-color: rgba(114, 169, 255, .3); background: rgba(114, 169, 255, .1); }
.remove-member:hover { color: #ffd0d4; border-color: rgba(255, 122, 133, .25); background: rgba(255, 122, 133, .09); }

.media-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(300px, .75fr); gap: 28px; }
.media-block { min-width: 0; }
.media-title { margin-bottom: 18px; }
.media-title h3 { margin: 0 0 5px; font-size: 17px; }
.media-title p, .current-file { margin: 0; color: var(--muted); font-size: 12px; }
.background-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
.background-item { position: relative; min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-raised); }
.background-item img { width: 100%; aspect-ratio: 16 / 10; display: block; object-fit: cover; }
.background-item span { min-height: 42px; padding: 8px 10px; display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 11px; line-height: 1.3; }
.upload { min-height: 54px; padding: 10px 14px; display: flex; align-items: center; justify-content: space-between; gap: 14px; border: 1px dashed var(--line-strong); border-radius: 14px; color: #d9e2f2; background: var(--surface-raised); cursor: pointer; }
.upload:hover { border-color: var(--accent); }
.upload input { max-width: 55%; color: var(--muted); font-size: 12px; }
.music-settings { display: grid; align-content: start; gap: 18px; }
.music-settings .media-title { margin: 0; }
.music-toolbar { display: flex; align-items: end; justify-content: space-between; gap: 28px; }
.volume-field { width: min(360px, 100%); }
.track-editor { display: grid; gap: 10px; }
.track-row { padding: 14px; display: grid; grid-template-columns: 42px minmax(160px, 1fr) minmax(150px, .8fr) minmax(220px, .9fr) auto; align-items: end; gap: 12px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface-raised); }
.track-number { width: 38px; height: 38px; align-self: end; display: grid; place-items: center; border-radius: 12px; color: var(--accent); background: rgba(114, 169, 255, .1); font-size: 12px; font-weight: 750; font-variant-numeric: tabular-nums; }
.track-row audio { width: 100%; min-width: 210px; height: 42px; color-scheme: dark; }
.remove-track { min-height: 42px; padding: 0 10px; display: flex; align-items: center; gap: 7px; border-radius: 11px; color: var(--muted); font-size: 12px; cursor: pointer; }
.remove-track:hover { color: #ffd0d4; background: rgba(255, 122, 133, .09); }
.empty-state { margin: 0; padding: 24px; border: 1px dashed var(--line); border-radius: 14px; color: var(--muted); text-align: center; font-size: 13px; }
.music-upload { margin-top: 2px; }
input[type="range"] { width: 100%; accent-color: var(--accent-strong); cursor: pointer; }

.preview-frame { overflow: hidden; border: 1px solid var(--line-strong); border-radius: 22px; background: #000; box-shadow: var(--shadow); }
.preview-frame iframe { width: 100%; aspect-ratio: 16 / 9; display: block; border: 0; }
.savebar { position: fixed; z-index: 25; left: max(22px, calc((100vw - 1160px) / 2 + 180px)); right: max(22px, calc((100vw - 1480px) / 2)); bottom: 18px; min-height: 70px; padding: 12px 14px 12px 20px; display: flex; align-items: center; justify-content: space-between; gap: 18px; border: 1px solid var(--line-strong); border-radius: 20px; background: rgba(10, 23, 48, .82); box-shadow: 0 18px 56px rgba(0, 0, 0, .42), inset 0 1px 0 rgba(255, 255, 255, .1); backdrop-filter: blur(28px) saturate(1.35); }
.savebar p { margin: 0; display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.savebar > div { display: flex; gap: 10px; }
.save-dot { flex: none; background: var(--accent); box-shadow: 0 0 0 4px rgba(114, 169, 255, .1); }

@media (max-width: 1050px) {
  .dashboard { grid-template-columns: 1fr; gap: 20px; }
  .sidebar { position: static; overflow-x: auto; display: flex; padding-bottom: 5px; }
  .sidebar a { flex: none; }
  .team-row { grid-template-columns: 44px repeat(2, minmax(140px, 1fr)) auto; }
  .team-row .team-field-name { grid-column: 2; grid-row: 1; }
  .team-row .team-field-category { grid-column: 3; grid-row: 1; }
  .team-row .team-field-position { grid-column: 2; grid-row: 2; }
  .team-row .team-field-discord { grid-column: 3; grid-row: 2; }
  .team-row .team-row-actions { grid-column: 4; grid-row: 1; }
  .discord-feedback { grid-column: 2 / 4; }
  .media-grid { grid-template-columns: 1fr; }
  .track-row { grid-template-columns: 42px repeat(2, minmax(0, 1fr)) auto; }
  .track-row audio { grid-column: 2 / 4; }
  .track-row .remove-track { grid-column: 4; grid-row: 1; }
  .savebar { left: 22px; }
}

@media (max-width: 680px) {
  .topbar { height: auto; min-height: 72px; padding: 10px 14px; }
  .top-actions .button { padding: 0 12px; }
  .admin-chip b { display: none; }
  .admin-chip { padding-right: 5px; }
  .dashboard { padding: 30px 14px 130px; }
  .fields-grid, .field-pair { grid-template-columns: 1fr; }
  .field-pair { grid-column: 1 / -1; }
  .section-heading { align-items: start; flex-direction: column; gap: 8px; }
  .section-heading > p { text-align: left; }
  .surface { padding: 16px; }
  .team-row { grid-template-columns: 44px minmax(0, 1fr) auto; align-items: center; }
  .team-row .field { grid-column: 1 / -1; grid-row: auto; }
  .team-row .team-row-actions { grid-column: 3; grid-row: 1; }
  .discord-feedback { grid-column: 1 / -1; }
  .background-list { grid-template-columns: 1fr; }
  .music-toolbar { align-items: stretch; flex-direction: column; }
  .track-row { grid-template-columns: 42px minmax(0, 1fr) auto; align-items: center; }
  .track-row .field, .track-row audio { grid-column: 1 / -1; }
  .track-row .remove-track { grid-column: 3; grid-row: 1; }
  .savebar { left: 10px; right: 10px; bottom: 10px; align-items: stretch; flex-direction: column; }
  .savebar p { display: none; }
  .savebar > div { display: grid; grid-template-columns: 1fr; }
  .savebar .button { width: 100%; }
  .auth-card { padding: 26px 20px; border-radius: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

@media (prefers-contrast: more), (prefers-reduced-transparency: reduce) {
  .auth-card, .topbar, .savebar { background: #08142b; backdrop-filter: none; }
  :root { --line: rgba(210, 225, 255, .42); --line-strong: rgba(230, 239, 255, .7); }
}
