:root {
  --bg: #f6f7ff;
  --card: #ffffff;
  --ink: #20243a;
  --muted: #6b7287;
  --primary: #6259f8;
  --primary-dark: #4d45cf;
  --primary-soft: #efefff;
  --accent: #ffb703;
  --good: #168a4f;
  --good-bg: #e8fff1;
  --danger: #c72f55;
  --danger-bg: #fff0f4;
  --warning: #8a6400;
  --warning-bg: #fff6d8;
  --line: #e3e5f0;
  --shadow: 0 12px 32px rgba(49, 44, 99, 0.11);
  --radius: 20px;
  --tap: 46px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 280px;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 3%, #e8e5ff 0 12rem, transparent 12.2rem),
    radial-gradient(circle at 95% 0%, #fff0c7 0 9rem, transparent 9.2rem),
    var(--bg);
  font-family: Inter, ui-rounded, "Segoe UI", system-ui, -apple-system, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }

:focus-visible {
  outline: 3px solid #2f69ff;
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 100;
  padding: 10px 14px;
  border-radius: 12px;
  color: #fff;
  background: #20243a;
  transform: translateY(-150%);
}
.skip-link:focus { transform: translateY(0); }

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.noscript-card, .boot-screen, .login-wrap {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.boot-card, .noscript-card {
  width: min(440px, 100%);
  padding: 28px;
  text-align: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.spinner {
  width: 42px;
  height: 42px;
  margin: 0 auto 16px;
  border: 4px solid #e3e1ff;
  border-top-color: var(--primary);
  border-radius: 999px;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 14px 14px calc(92px + env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin: 4px 0 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  font-size: 1.12rem;
  font-weight: 950;
}

.brand-badge {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 1.4rem;
  background: linear-gradient(135deg, var(--primary), #9b5cff);
  border-radius: 15px;
  box-shadow: var(--shadow);
}

.top-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.pill, .status, .module-tag {
  display: inline-flex;
  align-items: center;
  width: max-content;
  max-width: 100%;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 900;
}

.pill {
  min-height: 38px;
  padding: 7px 11px;
  background: #fff;
  border: 1px solid var(--line);
}
.pill-button { color: var(--ink); cursor: pointer; }
.pill-button:hover { border-color: #bbb7ff; background: #f7f6ff; }

.connection-banner {
  position: sticky;
  top: 6px;
  z-index: 12;
  margin: 0 0 12px;
  padding: 10px 14px;
  color: var(--warning);
  font-weight: 800;
  font-size: 0.9rem;
  background: var(--warning-bg);
  border: 1px solid #f0d887;
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.tabs {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  padding: 7px 7px calc(7px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.96);
  border-top: 1px solid var(--line);
  box-shadow: 0 -10px 30px rgba(49, 44, 99, 0.11);
  backdrop-filter: blur(14px);
}
.tabs-1 { grid-template-columns: 1fr; }

.tab {
  min-height: 54px;
  padding: 7px 3px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 13px;
  font-size: 0.72rem;
  font-weight: 900;
  line-height: 1.15;
}
.tab-icon { display: block; margin-bottom: 3px; font-size: 1.2rem; }
.tab.active { color: var(--primary-dark); background: var(--primary-soft); }

.card {
  min-width: 0;
  padding: 18px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(227, 229, 240, 0.96);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.hero {
  position: relative;
  overflow: hidden;
  padding: 22px;
  color: #fff;
  background: linear-gradient(135deg, #5f57f6, #955af2 68%, #b16bf4);
}
.hero::after {
  content: "⭐";
  position: absolute;
  right: 18px;
  top: 10px;
  font-size: 5rem;
  opacity: 0.12;
  transform: rotate(11deg);
  pointer-events: none;
}
.hero h1 { position: relative; z-index: 1; margin: 0 0 8px; font-size: clamp(1.75rem, 8vw, 3rem); line-height: 1.08; }
.hero p { position: relative; z-index: 1; max-width: 720px; margin: 0; color: #f1efff; font-weight: 650; }

.grid { display: grid; gap: 14px; }
.grid-2, .grid-3 { grid-template-columns: 1fr; }
.grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stack { display: flex; flex-direction: column; gap: 12px; }
.gap-top { margin-top: 14px; }

h1, h2, h3, h4 { overflow-wrap: anywhere; }
h2 { font-size: 1.3rem; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 24px 0 10px;
}
.section-title h2 { margin: 0; }

.muted, .small { color: var(--muted); }
.small { font-size: 0.87rem; }
.strong { font-weight: 900; }
.footer { padding: 28px 0 0; text-align: center; color: var(--muted); font-size: 0.82rem; }

.kpi { padding: 16px; }
.kpi .icon { margin-bottom: 8px; font-size: 1.5rem; }
.kpi .num { font-size: 1.75rem; font-weight: 950; letter-spacing: -0.04em; }
.kpi .label { color: var(--muted); font-size: 0.86rem; font-weight: 750; }

.progress {
  display: block;
  width: 100%;
  height: 16px;
  overflow: hidden;
  appearance: none;
  -webkit-appearance: none;
  background: #eceefa;
  border: 1px solid #e1e3ef;
  border-radius: 999px;
}
.progress::-webkit-progress-bar {
  background: #eceefa;
  border-radius: 999px;
}
.progress::-webkit-progress-value {
  background: linear-gradient(90deg, #ffb703, #ff7b54, #8f5cff);
  border-radius: 999px;
}
.progress::-moz-progress-bar {
  background: linear-gradient(90deg, #ffb703, #ff7b54, #8f5cff);
  border-radius: 999px;
}

.btn {
  min-height: var(--tap);
  max-width: 100%;
  padding: 10px 15px;
  border: 0;
  border-radius: 14px;
  font-weight: 900;
  transition: transform 0.15s, filter 0.15s;
}
.btn:hover { filter: brightness(0.98); transform: translateY(-1px); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { cursor: not-allowed; opacity: 0.48; transform: none; }
.btn-primary { color: #fff; background: linear-gradient(135deg, var(--primary), #9258ed); }
.btn-soft { color: var(--primary-dark); background: var(--primary-soft); }
.btn-good { color: var(--good); background: var(--good-bg); }
.btn-danger { color: var(--danger); background: var(--danger-bg); }
.btn-warning { color: var(--warning); background: var(--warning-bg); }
.btn-block { width: 100%; }
.btn-compact { min-height: 40px; padding: 8px 11px; font-size: 0.86rem; }
.button-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.field { display: flex; flex-direction: column; gap: 6px; margin: 12px 0; }
.field label, .field-label { font-size: 0.9rem; font-weight: 850; }
.field-hint { margin: 0; color: var(--muted); font-size: 0.8rem; }
.field input, .field select, .field textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 11px 13px;
  color: var(--ink);
  background: #fbfbfe;
  border: 1px solid #d9dce9;
  border-radius: 13px;
  outline: none;
}
.field textarea { min-height: 92px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 4px #eceaff; }
.field input[aria-invalid="true"] { border-color: var(--danger); }
.checkbox-field { flex-direction: row; align-items: flex-start; }
.checkbox-field input { width: 24px; min-height: 24px; flex: 0 0 auto; margin: 2px 0 0; }
.checkbox-field label { cursor: pointer; }

.notice {
  margin: 13px 0;
  padding: 11px 13px;
  color: #4c4590;
  background: #f6f4ff;
  border: 1px solid #e5e1ff;
  border-radius: 14px;
  font-size: 0.89rem;
}
.notice.success { color: #116d41; background: var(--good-bg); border-color: #c7f3d8; }
.notice.error { color: #9d2647; background: var(--danger-bg); border-color: #f5cad6; }
.notice.warning { color: var(--warning); background: var(--warning-bg); border-color: #f0d887; }

.login-card {
  width: min(920px, 100%);
  overflow: hidden;
  padding: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
}
.login-art {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 28px 24px;
  color: #fff;
  background: linear-gradient(145deg, #6259f8, #9c5af1);
}
.login-art h1 { margin: 0; font-size: clamp(2rem, 10vw, 3rem); line-height: 1.04; }
.login-art p { margin: 0; color: #f0ecff; }
.login-form { padding: 24px; }
.login-form h2 { margin: 0 0 4px; }

.task, .row {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}
.task:last-child, .row:last-child { border-bottom: 0; }
.task-main, .person { display: flex; align-items: flex-start; gap: 11px; min-width: 0; }
.task-main > :last-child, .person > :last-child { min-width: 0; }
.task-icon, .avatar {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  font-size: 1.35rem;
  background: #f1efff;
  border-radius: 14px;
}
.task h3, .task h4 { margin: 0 0 3px; }
.task p { margin: 0; color: var(--muted); font-size: 0.88rem; }
.list { display: flex; flex-direction: column; }
.empty { padding: 24px 8px; color: var(--muted); text-align: center; }

.status { padding: 5px 9px; }
.status-good { color: var(--good); background: var(--good-bg); }
.status-wait { color: var(--warning); background: var(--warning-bg); }
.status-bad { color: var(--danger); background: var(--danger-bg); }

.reward-card, .module { display: flex; min-height: 205px; flex-direction: column; justify-content: space-between; gap: 14px; }
.reward-icon, .module .big { font-size: 2.6rem; }
.reward-title { font-size: 1.05rem; font-weight: 900; }
.reward-cost, .badge-points { color: var(--primary-dark); font-weight: 950; }
.module h3 { margin: 7px 0 4px; }
.module p { margin: 0; color: var(--muted); }
.module-tag { padding: 5px 8px; color: var(--primary-dark); background: var(--primary-soft); }
.narrow-card { width: min(560px, 100%); margin-right: auto; margin-left: auto; }
.resume-card { border-color: #b9e6cd; background: #f7fff9; }

.quiz-box { padding: 18px; }
.quiz-q { margin: 8px 0 17px; font-size: 1.25rem; font-weight: 950; }
.answers { display: grid; grid-template-columns: 1fr; gap: 9px; }
.answer {
  min-height: var(--tap);
  padding: 12px;
  color: var(--ink);
  text-align: left;
  font-weight: 900;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
}
.answer:hover { border-color: #8b81ff; background: #f7f6ff; }
.answer.correct { border-color: #29b66c; background: var(--good-bg); }
.answer.wrong { border-color: #ef476f; background: var(--danger-bg); }
.retry-box { display: grid; gap: 10px; margin-top: 14px; padding: 12px; background: var(--warning-bg); border: 1px solid #efcf83; border-radius: 14px; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: end center;
  padding: 18px 12px calc(18px + env(safe-area-inset-bottom));
  background: rgba(23, 22, 41, 0.5);
}
.modal {
  width: min(560px, 100%);
  max-height: min(88vh, 760px);
  overflow: auto;
  padding: 20px;
  background: #fff;
  border-radius: 22px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.24);
}
.modal h2 { margin-top: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; flex-wrap: wrap; }

.music-lab { margin-top: 14px; }
.instrument-panel { min-width: 0; padding: 14px; background: #fbfbff; border: 1px solid var(--line); border-radius: 18px; }
.instrument-head { margin-bottom: 10px; }
.instrument-examples { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin-top: 12px; }
.piano {
  position: relative;
  display: flex;
  width: 100%;
  height: 145px;
  overflow: hidden;
  background: #252631;
  border: 1px solid #cfd2dd;
  border-radius: 13px;
}
.piano-key { position: relative; min-width: 0; border: 0; touch-action: manipulation; }
.piano-key.white {
  z-index: 1;
  width: 12.5%;
  height: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0 1px 9px;
  color: #343746;
  background: linear-gradient(#fff, #f1f1f4);
  border-right: 1px solid #b7bac5;
  font-size: 0.78rem;
}
.piano-key.black {
  position: absolute;
  top: 0;
  z-index: 3;
  width: 7.5%;
  height: 62%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0 0 8px;
  color: #fff;
  background: linear-gradient(#30313a, #101116);
  border-radius: 0 0 7px 7px;
  font-size: 0.6rem;
}
.piano-key.black-pos-1 { left: 8.75%; }
.piano-key.black-pos-2 { left: 21.25%; }
.piano-key.black-pos-3 { left: 46.25%; }
.piano-key.black-pos-4 { left: 58.75%; }
.piano-key.black-pos-5 { left: 71.25%; }
.piano-key.is-active { background: #ffe49a; box-shadow: inset 0 0 0 3px #ffb703; }
.piano-key.black.is-active { background: #8e6b06; }
.guitar-scroll { overflow-x: auto; padding-bottom: 4px; }
.guitar-grid { min-width: 520px; }
.guitar-fret-header, .guitar-string-row { display: grid; grid-template-columns: 58px repeat(5, minmax(72px, 1fr)); align-items: center; }
.guitar-fret-header { padding-bottom: 4px; color: var(--muted); font-size: 0.74rem; font-weight: 850; text-align: center; }
.guitar-string-name { font-weight: 950; text-align: center; }
.guitar-string-row { position: relative; min-height: 45px; }
.guitar-string-row::after { content: ""; position: absolute; right: 0; left: 58px; top: 50%; z-index: 0; height: 2px; background: #8b8c94; }
.guitar-fret { position: relative; z-index: 1; min-height: 40px; margin: 2px 4px; background: #fff; border: 1px solid #dadce7; border-radius: 9px; font-weight: 850; }
.guitar-fret.is-active { background: #fff1bd; border-color: #ffb703; box-shadow: 0 0 0 2px rgba(255, 183, 3, 0.2); }

.privacy-note { display: flex; align-items: flex-start; gap: 9px; }
.privacy-note > :first-child { flex: 0 0 auto; }
.danger-zone { border-color: #f0b7c6; }
.one-time-secret {
  display: block;
  margin: 16px 0;
  padding: 18px;
  color: #2f286c;
  background: #f2f0ff;
  border: 2px dashed #7b71ff;
  border-radius: 16px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: clamp(1.8rem, 10vw, 3rem);
  font-weight: 950;
  letter-spacing: 0.12em;
  text-align: center;
  user-select: all;
}
.download-link { position: fixed; left: -9999px; }

@media (min-width: 560px) {
  .shell { padding: 20px 20px calc(96px + env(safe-area-inset-bottom)); }
  .answers { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .task, .row { flex-direction: row; align-items: center; justify-content: space-between; }
  .task > .button-row, .row > .button-row { justify-content: flex-end; }
  .modal-backdrop { place-items: center; }
}

@media (min-width: 760px) {
  .login-card { display: grid; grid-template-columns: 1.05fr 0.95fr; }
  .login-art { min-height: 560px; padding: 38px; justify-content: space-between; }
  .login-form { padding: 38px; align-self: center; }
  .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .topbar { align-items: center; }
}

@media (min-width: 900px) {
  .shell { padding: 26px; }
  .tabs {
    position: static;
    display: flex;
    width: max-content;
    max-width: 100%;
    margin-bottom: 18px;
    padding: 7px;
    border: 1px solid var(--line);
    border-radius: 17px;
    box-shadow: var(--shadow);
  }
  .tab { min-width: 120px; min-height: 44px; padding: 9px 13px; font-size: 0.88rem; }
  .tab-icon { display: inline; margin: 0 5px 0 0; }
  .grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .footer { padding-bottom: 20px; }
  .piano { height: 180px; }
}

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

@media (prefers-contrast: more) {
  :root { --line: #8b8fa3; --muted: #4d5163; }
  .card, .tabs, .field input, .field select, .field textarea { border-width: 2px; }
}
