:root {
  --bg-start: #edf2f8;
  --bg-end: #dfe8f3;
  --ink: #1f2a36;
  --muted: #607081;
  --line: rgba(255, 255, 255, 0.58);
  --glass: rgba(255, 255, 255, 0.33);
  --glass-strong: rgba(255, 255, 255, 0.56);
  --accent: #5a8fb2;
  --accent-strong: #417ca3;
  --danger: #9b4b4b;
  --good: #3f8b69;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: "Manrope", "Segoe UI", sans-serif;
  color: var(--ink);
}

body {
  background: linear-gradient(150deg, var(--bg-start), var(--bg-end));
}

.bg-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.bg-one {
  background:
    radial-gradient(700px 420px at 8% 4%, rgba(138, 179, 220, 0.32), transparent 70%),
    radial-gradient(620px 420px at 88% 16%, rgba(191, 219, 236, 0.3), transparent 72%);
}

.bg-two {
  background:
    radial-gradient(620px 420px at 50% 102%, rgba(186, 204, 227, 0.3), transparent 75%),
    radial-gradient(540px 320px at 92% 96%, rgba(236, 240, 248, 0.4), transparent 72%);
}

.app-shell {
  position: relative;
  z-index: 1;
  max-width: 1080px;
  margin: 0 auto;
  padding: 14px 12px 20px;
}

.glass.panel {
  background: linear-gradient(150deg, var(--glass-strong), var(--glass));
  border: 1px solid var(--line);
  border-radius: 24px;
  backdrop-filter: blur(16px) saturate(120%);
  -webkit-backdrop-filter: blur(16px) saturate(120%);
  box-shadow: 0 14px 50px rgba(43, 56, 70, 0.13), inset 0 1px 0 rgba(255, 255, 255, 0.68);
}

.hero-panel {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  align-items: flex-start;
}

.eyebrow {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.14em;
  font-weight: 800;
  text-transform: uppercase;
  color: #5b6f82;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  margin-top: 8px;
  font-size: 30px;
  line-height: 1.14;
  letter-spacing: -0.02em;
}

.subtitle {
  margin-top: 8px;
  max-width: 720px;
  color: #4d5f71;
}

.top-actions {
  display: flex;
  gap: 8px;
}

.tab-btn,
.tool-btn,
.ghost-btn,
.cta-btn,
.footer-btn,
.formula-btn,
.quick-btn {
  border: 1px solid rgba(255, 255, 255, 0.75);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.72);
  color: #263648;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  padding: 9px 12px;
}

.tab-btn.active,
.tool-btn.active,
.footer-btn.active {
  color: #fff;
  background: linear-gradient(150deg, var(--accent), var(--accent-strong));
  border-color: rgba(83, 131, 162, 0.7);
}

.view {
  display: none;
  margin-top: 12px;
  gap: 12px;
}

.view.active {
  display: grid;
}

.config-panel,
.kim-panel,
.quick-panel,
.result-panel,
.solver-head-panel,
.question-panel,
.workspace-panel,
.answer-panel,
.stats-panel {
  padding: 14px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.section-head h2,
.question-panel h2,
.stats-panel h2,
.workspace-panel h3,
.answer-panel h3,
.kim-panel h2,
.quick-panel h2 {
  font-size: 16px;
  letter-spacing: 0.01em;
}

.status-pill {
  font-size: 12px;
  font-weight: 700;
  color: #48647c;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.92);
  border-radius: 999px;
  padding: 6px 10px;
}

.status-pill.bad {
  color: #914b4b;
  background: rgba(255, 235, 235, 0.76);
}

.status-pill.ok {
  color: #326b50;
  background: rgba(232, 248, 239, 0.8);
}

.selector-grid {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

label span {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  color: #5a6e80;
  font-weight: 700;
}

select,
input {
  width: 100%;
  border: 1px solid rgba(73, 95, 117, 0.2);
  background: rgba(255, 255, 255, 0.85);
  border-radius: 12px;
  padding: 12px;
  color: var(--ink);
  font-size: 14px;
}

.muted {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.start-block {
  margin-top: 12px;
  display: grid;
  gap: 10px;
}

.start-hint {
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.85);
  background: rgba(255, 255, 255, 0.58);
  padding: 10px;
  font-size: 13px;
  color: #4c6073;
}

.cta-btn.big {
  height: 44px;
  font-size: 15px;
}

.cta-btn {
  background: linear-gradient(150deg, var(--accent), var(--accent-strong));
  border-color: rgba(81, 124, 153, 0.7);
  color: #fff;
}

.cta-btn:disabled,
.ghost-btn:disabled,
.tool-btn:disabled,
.quick-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.task-list {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  max-height: 260px;
  overflow: auto;
  padding-right: 2px;
}

.task-pill {
  border: 1px solid rgba(255, 255, 255, 0.84);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.62);
  padding: 8px;
  font-size: 12px;
  text-align: center;
  font-weight: 700;
  color: #3f5569;
}

.quick-grid {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.quick-btn {
  text-align: center;
  background: rgba(255, 255, 255, 0.8);
}

.result-panel {
  border: 1px solid rgba(120, 171, 145, 0.32);
  background: linear-gradient(150deg, rgba(231, 248, 239, 0.8), rgba(255, 255, 255, 0.6));
}

.solver-progress-row {
  display: grid;
  grid-template-columns: 90px 1fr auto;
  gap: 8px;
  align-items: center;
  font-weight: 800;
}

.ghost-btn.danger {
  color: #fff;
  background: linear-gradient(145deg, #a55959, #8f4646);
}

.question-media {
  margin-top: 10px;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(74, 94, 113, 0.2);
  background: rgba(255, 255, 255, 0.7);
}

.question-media img {
  display: block;
  width: 100%;
  max-height: 420px;
  object-fit: contain;
}

.question-text {
  margin-top: 10px;
  line-height: 1.58;
  white-space: pre-wrap;
}

.options-list {
  margin-top: 10px;
  display: grid;
  gap: 8px;
}

.option-btn {
  text-align: left;
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.73);
  padding: 10px;
  font-size: 14px;
  cursor: pointer;
}

.option-btn.active {
  border-color: rgba(88, 139, 171, 0.74);
  background: linear-gradient(150deg, rgba(210, 231, 245, 0.9), rgba(242, 249, 255, 0.88));
}

.draw-toolbar {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.width-row {
  display: flex;
  gap: 8px;
}

#scratchCanvas {
  width: 100%;
  margin-top: 10px;
  border-radius: 14px;
  border: 1px dashed rgba(95, 112, 129, 0.35);
  background: rgba(255, 255, 255, 0.72);
  touch-action: none;
}

.chips,
.formula-row {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.chip {
  white-space: nowrap;
  border: 1px solid rgba(255, 255, 255, 0.87);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.75);
  padding: 8px 11px;
  font-size: 12px;
  color: #506172;
  cursor: pointer;
}

.answer-row {
  margin-top: 12px;
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 8px;
}

.feedback {
  margin-top: 10px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.82);
  background: rgba(255, 255, 255, 0.73);
  padding: 10px;
  font-size: 14px;
  line-height: 1.45;
}

.feedback.ok {
  border-color: rgba(96, 171, 134, 0.5);
  background: rgba(234, 249, 241, 0.86);
}

.feedback.bad {
  border-color: rgba(184, 101, 101, 0.48);
  background: rgba(255, 238, 238, 0.86);
}

.stats-summary {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.stat-box {
  border: 1px solid rgba(255, 255, 255, 0.84);
  border-radius: 12px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.68);
}

.stat-val {
  font-size: 20px;
  font-weight: 800;
}

.stat-label {
  font-size: 12px;
  margin-top: 4px;
  color: #5a6b7d;
}

.stats-subjects,
.stats-recent {
  margin-top: 10px;
  display: grid;
  gap: 8px;
}

.list-row {
  border: 1px solid rgba(255, 255, 255, 0.82);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.67);
  padding: 10px;
  line-height: 1.5;
}

.footer-panel {
  margin-top: 12px;
  padding: 10px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  z-index: 99;
  border: 1px solid rgba(255, 255, 255, 0.86);
  border-radius: 12px;
  padding: 10px 12px;
  background: rgba(29, 45, 61, 0.88);
  color: #f5f9fd;
  font-size: 13px;
  max-width: min(90vw, 600px);
}

.toast.bad {
  background: rgba(120, 45, 45, 0.92);
}

.hidden {
  display: none !important;
}

@media (max-width: 1020px) {
  .selector-grid,
  .stats-summary {
    grid-template-columns: 1fr;
  }

  .task-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .quick-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .answer-row {
    grid-template-columns: 1fr 1fr;
  }

  .footer-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 740px) {
  .hero-panel {
    flex-direction: column;
  }

  h1 {
    font-size: 25px;
  }

  .task-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .solver-progress-row {
    grid-template-columns: 80px 1fr;
  }

  .solver-progress-row .danger {
    grid-column: span 2;
  }

  .answer-row {
    grid-template-columns: 1fr;
  }
}
