/* Mikhail.Live BETA1 design system.
   Premium chess-tech / serious AI coach.
   - midnight navy + gold accent + teal accent
   - large radius / soft borders / no clutter
   - reusable card / button / chip classes
*/
:root {
  --bg-deep: #07101e;
  --bg: #0b1626;
  --surface: #122036;
  --surface-2: #18283f;
  --surface-elev: #1d3050;
  --border: rgba(232, 200, 112, 0.18);
  --border-soft: rgba(255, 255, 255, 0.06);
  --text: #e9eef5;
  --text-dim: #a3b1c4;
  --text-mute: #6e7e93;
  --gold: #e8c870;
  --gold-soft: rgba(232, 200, 112, 0.12);
  --teal: #4dd8c4;
  --teal-soft: rgba(77, 216, 196, 0.12);
  --red: #ef6b6b;
  --green: #5dd39e;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow-soft: 0 10px 30px rgba(0, 0, 0, 0.35);
  --shadow-card: 0 6px 18px rgba(0, 0, 0, 0.28);
  --mono: "JetBrains Mono", "Menlo", "Consolas", monospace;
  --sans: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg-deep);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  min-height: 100%;
}
body {
  background:
    radial-gradient(1200px 600px at 80% -10%,
      rgba(77, 216, 196, 0.06), transparent 70%),
    radial-gradient(1000px 700px at -10% 20%,
      rgba(232, 200, 112, 0.05), transparent 70%),
    linear-gradient(180deg, var(--bg-deep) 0%, #06090f 100%);
  background-attachment: fixed;
}
a { color: var(--teal); text-decoration: none; }
a:hover { color: #7be5d3; }
h1, h2, h3, h4 { color: var(--text); margin: 0 0 .4em; font-weight: 600; }
h1 { font-size: 28px; letter-spacing: -0.01em; }
h2 { font-size: 20px; }
h3 { font-size: 16px; letter-spacing: .02em; text-transform: uppercase;
     color: var(--text-dim); }
p { margin: 0 0 .8em; color: var(--text-dim); }
small { color: var(--text-mute); }

/* layout shell */
.app-shell {
  min-height: 100vh;
  display: flex; flex-direction: column;
}
.app-nav {
  display: flex; align-items: center;
  gap: 18px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--border-soft);
  background: rgba(7, 16, 30, 0.92);
  backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 50;
}
.app-nav .brand {
  display: flex; align-items: center; gap: 10px;
  color: var(--text); font-weight: 700; font-size: 17px;
  letter-spacing: .02em;
}
.app-nav .brand .dot { color: var(--gold); }
.app-nav .links {
  display: flex; gap: 4px; flex: 1; margin-left: 12px;
  flex-wrap: wrap;
}
.app-nav .links a {
  padding: 6px 12px;
  border-radius: 999px;
  color: var(--text-dim);
  font-size: 13px;
}
.app-nav .links a.active,
.app-nav .links a:hover {
  background: var(--surface-2);
  color: var(--text);
}
.app-nav .profile-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  color: var(--text); font-size: 13px;
}
.app-nav .profile-chip .name { font-weight: 600; }
.app-nav .profile-chip .rating { color: var(--gold); font-weight: 700; }
.app-nav .profile-chip .band { color: var(--text-mute); }
.app-nav .cta {
  background: linear-gradient(180deg, var(--gold), #c9a85a);
  color: #0a1422;
  font-weight: 700;
  padding: 8px 16px;
  border-radius: 999px;
  border: none; cursor: pointer;
  font-size: 13px;
}
.app-nav .cta:hover { filter: brightness(1.05); }

.app-main {
  width: 100%; max-width: 1240px;
  margin: 0 auto; padding: 28px;
}

/* hero */
.hero {
  background:
    linear-gradient(135deg, rgba(232, 200, 112, 0.07),
      rgba(77, 216, 196, 0.04));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  display: grid;
  grid-template-columns: 1.4fr .8fr;
  gap: 32px;
  align-items: center;
  margin-bottom: 28px;
  box-shadow: var(--shadow-soft);
}
.hero .kicker {
  display: inline-block;
  font-family: var(--mono); font-size: 11px;
  color: var(--gold); letter-spacing: .18em;
  text-transform: uppercase; margin-bottom: 10px;
}
.hero h1 {
  font-size: 32px; line-height: 1.15;
}
.hero p { font-size: 16px; max-width: 540px; }
.hero .ctarow { display: flex; gap: 12px; margin-top: 16px;
                flex-wrap: wrap; }
.hero img.hero-img {
  width: 100%; max-width: 300px;
  border-radius: 14px;
  justify-self: end;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border-soft);
}
@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; }
  .hero img.hero-img { justify-self: center; }
}
/* Beta1.PROD brand polish */
.app-nav .brand-logo {
  height: 34px; width: auto; display: block;
}
@media (max-width: 600px) { .app-nav .brand-logo { height: 28px; } }

/* Mobile (iPhone Safari etc.): the nav must SCROLL AWAY with the page,
 * never stay fixed/sticky over content. The 12 links collapse into one
 * compact horizontally-scrollable strip instead of stacking into a tall
 * block that buries the page title underneath it. */
@media (max-width: 760px) {
  .app-nav {
    position: static;          /* was sticky - title now scrolls normally */
    top: auto;
    flex-wrap: nowrap;
    gap: 10px;
    padding: 10px 12px;
  }
  .app-nav .links {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 14px;
    min-width: 0;
  }
  .app-nav .links::-webkit-scrollbar { display: none; }
  .app-nav .links a { white-space: nowrap; }
  .app-nav .profile-chip { display: none; }   /* shown on the dashboard */
  .app-nav .cta { white-space: nowrap; }
  .section-header { margin: 16px 0 10px; }
  /* No giant hero/banner crowding content on a phone: compact the
   * dashboard hero, drop the decorative king, stack the cards, and keep
   * everything inside the viewport (no horizontal scroll). */
  .hero {
    padding: 16px 14px;
    gap: 12px;
    margin-bottom: 16px;
    grid-template-columns: 1fr;
  }
  .hero h1 { font-size: 21px; line-height: 1.25; }
  .hero p { font-size: 13.5px; }
  .hero .kicker { font-size: 10px; }
  .hero .hero-img { display: none; }
  .hero .ctarow { gap: 8px; }
  .grid.grid-two, .grid.grid-cards { grid-template-columns: 1fr; gap: 12px; }
  .card, .card.elev { padding: 14px; }
  /* thumb-friendly controls + readable inputs */
  .btn { min-height: 42px; }
  .board-controls { gap: 8px; flex-wrap: wrap; }
  input, select { font-size: 16px; }   /* iOS won't zoom on focus */
  html, body { overflow-x: hidden; }
}
html, body { max-width: 100%; }
/* the brand king hero art is a tall crop - cap + crown-anchored */
.hero img.hero-img {
  max-height: 320px; object-fit: cover; object-position: 50% 18%;
}
.beta-note {
  display: inline-flex; align-items: center; gap: 8px;
  margin-top: 14px; padding: 7px 13px;
  background: var(--gold-soft); color: var(--gold);
  border: 1px solid rgba(232, 200, 112, 0.28);
  border-radius: 999px; font-size: 12.5px; font-weight: 600;
}
.auth-logo {
  display: block; margin: 0 auto 18px; height: 46px; width: auto;
}

/* card */
.card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-card);
}
.card.elev { background: var(--surface-elev); }
.card .title { font-size: 16px; font-weight: 600;
               color: var(--text); margin-bottom: 4px; }
.card .desc { font-size: 13px; color: var(--text-dim); margin-bottom: 14px; }
.card .footer { display: flex; gap: 10px; align-items: center;
                margin-top: 14px; }

/* button */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border-soft);
  padding: 9px 16px;
  border-radius: 10px;
  font-size: 14px; font-weight: 500;
  cursor: pointer; transition: all .15s;
}
.btn:hover { background: var(--surface-elev); border-color: var(--border); }
.btn.primary {
  background: linear-gradient(180deg, var(--gold), #c9a85a);
  color: #0a1422; border: none; font-weight: 700;
}
.btn.primary:hover { filter: brightness(1.05); }
.btn.secondary {
  background: transparent; border-color: var(--teal);
  color: var(--teal);
}
.btn.ghost {
  background: transparent; border-color: var(--border-soft);
  color: var(--text-dim);
}
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* chip / tag */
.chip {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--gold-soft); color: var(--gold);
  font-size: 11px; font-weight: 600;
  letter-spacing: .08em; text-transform: uppercase;
  /* BETA1.4: spacing so adjacent chips never visually run together
   * (the "GrandmasterEvidence" / "tacticsall" Coach Report bug). */
  margin: 0 6px 4px 0;
}
.chip.teal { background: var(--teal-soft); color: var(--teal); }
.chip.muted { background: var(--surface-2); color: var(--text-mute); }
/* Chess SAN must keep its case (Ng5, Ra8#) even inside an uppercase
 * chip/label - uppercasing notation reads wrong and loses B/b sense. */
.san-move { text-transform: none; letter-spacing: normal; }
/* Chip rows lay out as wrapped flex with a real gap so labels are
 * always separated. */
.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

/* form */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
  font-size: 11px; color: var(--text-mute);
  letter-spacing: .12em; text-transform: uppercase;
}
.field input, .field select, .field textarea {
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  color: var(--text);
  font-size: 14px;
  padding: 10px 12px;
  font-family: inherit;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--gold);
}
.field textarea { min-height: 120px; resize: vertical; }
.row {
  display: flex; gap: 14px; flex-wrap: wrap;
  align-items: flex-end;
}
.row > .field { flex: 1; min-width: 160px; }

/* grids */
.grid { display: grid; gap: 18px; }
.grid-cards { grid-template-columns: repeat(auto-fill,
              minmax(260px, 1fr)); }
.grid-two { grid-template-columns: 1.5fr 1fr; }
@media (max-width: 1000px) {
  .grid-two { grid-template-columns: 1fr; }
}

/* section header */
.section-header {
  display: flex; align-items: center;
  justify-content: space-between;
  margin: 30px 0 14px;
}
.section-header h2 {
  font-size: 13px; letter-spacing: .14em;
  color: var(--text-dim);
  text-transform: uppercase;
}
.section-header .meta { color: var(--text-mute); font-size: 13px; }

/* board area */
.board-wrap {
  background: var(--surface-elev);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 18px;
}
.board {
  display: grid; grid-template-columns: repeat(8, 1fr);
  width: 100%;
  max-width: 460px;
  aspect-ratio: 1 / 1;
  margin: 0 auto;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
  position: relative;
  user-select: none;
}
.sq {
  display: flex; align-items: center; justify-content: center;
  position: relative;
}
.sq.l { background: #cfd8dc; }
.sq.d { background: #4b6275; }
/* Last move: low-opacity wash (matches the trainer board). */
.sq.lastmv.l { background-color: rgba(77, 216, 196, 0.16); }
.sq.lastmv.d { background-color: rgba(77, 216, 196, 0.24); }
/* Selected: gold outline + soft glow, a whisper of fill only. */
.sq.sel {
  box-shadow: inset 0 0 0 2.5px rgba(232, 200, 112, 0.92),
              inset 0 0 12px rgba(232, 200, 112, 0.22);
}
.sq.sel.l { background-color: rgba(232, 200, 112, 0.14); }
.sq.sel.d { background-color: rgba(232, 200, 112, 0.20); }
.sq.tgt::after {
  content: ""; width: 22%; aspect-ratio: 1; height: auto;
  background: rgba(232, 200, 112, 0.55);
  border-radius: 50%;
}
.sq.d.tgt::after { background: rgba(245, 232, 196, 0.62); }
/* Capturable opponent piece: four corner markers (not a circle/ring). */
.sq.tgt.cap::after {
  position: absolute;
  inset: 0;
  width: auto; height: auto; aspect-ratio: auto;
  border: 0; border-radius: 0;
  background:
    linear-gradient(135deg, rgba(232,200,112,.9) 22%, transparent 22%) left top,
    linear-gradient(225deg, rgba(232,200,112,.9) 22%, transparent 22%) right top,
    linear-gradient(45deg,  rgba(232,200,112,.9) 22%, transparent 22%) left bottom,
    linear-gradient(315deg, rgba(232,200,112,.9) 22%, transparent 22%) right bottom;
  background-size: 32% 32%;
  background-repeat: no-repeat;
}
.sq .pc { width: 84%; height: 84%; cursor: grab; }
.sq .pc svg { width: 100%; height: 100%; }
.sq .co {
  position: absolute; font-size: 10px; color: rgba(0,0,0,.45);
  font-family: var(--mono);
}
.sq .co.f { bottom: 2px; right: 4px; }
.sq .co.r { top: 2px; left: 4px; }
.sq.d .co { color: rgba(255,255,255,.55); }

.board-controls {
  display: flex; gap: 8px; margin-top: 14px;
  flex-wrap: wrap;
}

/* explanation panel */
.explain-panel {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 22px;
  min-height: 200px;
}
.explain-panel h3 { color: var(--gold); margin-bottom: 8px;
                    letter-spacing: .04em; text-transform: none;
                    font-size: 14px; }
.explain-panel .stmt {
  color: var(--text);
  font-size: 15px; line-height: 1.6;
  margin-bottom: 14px;
}
.explain-panel .meta-row {
  display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap;
}
.explain-panel .lesson {
  border-left: 2px solid var(--gold);
  padding-left: 12px;
  color: var(--text-dim);
  font-size: 13px;
  font-style: italic;
  margin-top: 10px;
}
.explain-panel .compare-block {
  margin-top: 16px;
  padding: 14px;
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
}
.explain-panel .compare-block .label {
  font-size: 11px; color: var(--text-mute);
  text-transform: uppercase; letter-spacing: .12em;
  margin-bottom: 4px;
}
.explain-panel .compare-block .v {
  font-size: 16px; font-weight: 600; color: var(--text);
}
.explain-panel .compare-block.best .v { color: var(--teal); }

.depth-toggle {
  display: flex; gap: 6px; flex-wrap: wrap;
  margin-top: 16px;
}
.depth-toggle .btn { padding: 6px 12px; font-size: 12px; }
.depth-toggle .btn.active {
  border-color: var(--gold); color: var(--gold);
  background: var(--gold-soft);
}

/* key-moment list */
.km-list { display: flex; flex-direction: column; gap: 6px;
           margin-top: 14px; }
.km-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--bg);
  border: 1px solid var(--border-soft);
  cursor: pointer; transition: all .15s;
}
.km-item:hover { background: var(--surface-2); }
.km-item.active {
  border-color: var(--gold);
  background: var(--gold-soft);
}
.km-item .km-no {
  font-family: var(--mono); font-weight: 700;
  color: var(--gold);
  width: 28px; text-align: center;
}
.km-item .km-meta { flex: 1; font-size: 13px; color: var(--text); }
.km-item .km-cls {
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  font-weight: 600; text-transform: capitalize;
}
.km-item .km-cls.blunder { background: rgba(239, 107, 107, 0.18);
                            color: var(--red); }
.km-item .km-cls.mistake { background: rgba(232, 200, 112, 0.18);
                            color: var(--gold); }
.km-item .km-cls.inaccuracy { background: rgba(232, 200, 112, 0.08);
                               color: var(--gold); }
.km-item .km-cls.good { background: rgba(93, 211, 158, 0.16);
                         color: var(--green); }

/* leaderboard */
.lb-list { display: flex; flex-direction: column; gap: 4px;
           margin-top: 8px; }
.lb-row {
  display: grid;
  grid-template-columns: 24px 1fr 60px 90px 70px;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--bg);
  font-size: 13px;
}
.lb-row.head {
  background: transparent;
  color: var(--text-mute);
  font-size: 11px; letter-spacing: .14em;
  text-transform: uppercase;
}
.lb-row .lb-rank { color: var(--gold); font-weight: 700;
                   font-family: var(--mono); }
.lb-row .lb-rating { color: var(--text-dim); font-family: var(--mono); }
.lb-row .lb-pts { color: var(--teal); font-weight: 700; text-align: right; }
.lb-row .lb-acc { color: var(--text); text-align: right; }

/* toast */
.toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface-elev);
  border: 1px solid var(--gold);
  color: var(--text);
  padding: 12px 18px;
  border-radius: 12px;
  box-shadow: var(--shadow-soft);
  opacity: 0; pointer-events: none;
  transition: all .25s;
  z-index: 100;
  font-size: 14px;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* utility */
.muted { color: var(--text-mute); }
.dim { color: var(--text-dim); }
.gold { color: var(--gold); }
.teal { color: var(--teal); }
.hide { display: none !important; }
.spacer { flex: 1; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.center { text-align: center; }

/* loading state */
.loading {
  display: inline-block;
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text-dim);
  font-size: 13px;
}
.loading::after {
  content: "";
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--gold);
  margin-left: 6px;
  animation: pulse 1.2s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: .3; }
  50% { opacity: 1; }
}

/* empty state */
.empty {
  padding: 24px;
  text-align: center;
  color: var(--text-mute);
  font-size: 13px;
  border: 1px dashed var(--border-soft);
  border-radius: 12px;
}

/* footer */
.app-foot {
  margin-top: 60px; padding: 18px 28px;
  border-top: 1px solid var(--border-soft);
  display: flex; justify-content: space-between;
  font-size: 12px; color: var(--text-mute);
}

/* HumanBeta1.0 finalization: per-ply solution-line teaching panel */
.pt-line{margin:6px 0 0 0;padding-left:20px;}
.pt-line .pt-ply{margin:3px 0;line-height:1.4;}
.pt-line .pt-ply-opponent{opacity:.75;}
.pt-line .pt-ply-you{font-weight:600;}
