:root {
  color-scheme: light;
  --sky-50: #f3fbff;
  --sky-100: #dcf3ff;
  --sky-200: #bfe8fb;
  --sky-500: #63b9dd;
  --ink: #254052;
  --muted: #607788;
  --glass: rgba(255, 255, 255, 0.58);
  --glass-strong: rgba(255, 255, 255, 0.78);
  --line: rgba(99, 185, 221, 0.24);
  --green: #51b873;
  --green-soft: rgba(81, 184, 115, 0.18);
  --gold: #c99a19;
  --gold-soft: rgba(255, 216, 98, 0.35);
  --red: #d75b6a;
  --shadow: 0 22px 58px rgba(82, 153, 190, 0.22);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 15% 12%, rgba(255, 255, 255, 0.9) 0 14rem, transparent 15rem),
    linear-gradient(135deg, #eefaff 0%, #d9f3ff 45%, #f7fcff 100%);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0;
}

.glass {
  border: 1px solid rgba(255, 255, 255, 0.65);
  background: var(--glass);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 126px;
  padding: 26px;
  border-radius: 8px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--sky-500);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 6vw, 3.45rem);
  line-height: 1.05;
}

h2 {
  margin-bottom: 4px;
  font-size: 1.2rem;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(74px, 1fr));
  gap: 10px;
}

.stats span {
  display: grid;
  min-height: 68px;
  place-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.42);
  color: var(--muted);
  text-align: center;
}

.stats strong {
  display: block;
  color: var(--ink);
  font-size: 1.35rem;
}

.workspace {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 18px;
  margin-top: 18px;
}

.sidebar-stack {
  display: grid;
  align-self: start;
  gap: 18px;
}

.panel {
  min-width: 0;
  padding: 18px;
  border-radius: 8px;
}

.rounds-panel {
  align-self: start;
}

.dictionary-search-panel h2 {
  margin-bottom: 12px;
}

.study-panel {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  min-height: 500px;
}

.study-panel > .panel-head {
  grid-column: 1;
  margin-bottom: 0;
}

.study-panel > .start-test-button {
  grid-column: 2;
  grid-row: 1;
}

.study-panel > .notice,
.study-panel > .word-grid,
.study-panel > .detail-panel {
  grid-column: 1 / -1;
}

.round-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
  justify-content: space-between;
  width: 100%;
  max-width: 100%;
}

.round-title-row > div {
  flex: 0 1 auto;
  min-width: 0;
}

.compact-button {
  flex: 0 0 auto;
  width: auto;
  min-width: 138px;
  min-height: 34px;
  margin-right: 4px;
  padding: 0 14px;
  font-size: 0.86rem;
}

.detail-panel {
  padding-top: 2px;
}

.detail-frame-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  max-height: min(72vh, 760px);
  overflow: auto;
  padding-right: 4px;
}

.detail-frame-card[hidden] {
  display: none;
}

.detail-frame-grid h3 {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.95rem;
}

.detail-panel iframe {
  width: 100%;
  height: min(62vh, 620px);
  min-height: 420px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.7);
}

.quiz-panel {
  grid-column: 2;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.panel-head p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.primary-button,
.ghost-button {
  min-height: 42px;
  padding: 0 15px;
  border: 0;
  border-radius: 8px;
  font-weight: 800;
  white-space: nowrap;
}

.primary-button {
  background: linear-gradient(135deg, #75c7e7, #4eaed1);
  color: white;
  box-shadow: 0 12px 24px rgba(78, 174, 209, 0.28);
}

.primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.ghost-button {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.62);
  color: var(--ink);
}

.danger {
  color: var(--red);
}

.round-list {
  display: grid;
  gap: 10px;
  max-height: min(52vh, 520px);
  overflow-y: auto;
  padding-right: 4px;
}

.search-box {
  display: grid;
  gap: 8px;
  margin-top: 0;
}

.search-box label {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.search-box input {
  min-height: 42px;
}

.search-result-wrap {
  position: relative;
}

#searchPanel {
  padding-top: 0;
}

#searchFrame {
  height: min(72vh, 760px);
  min-height: 520px;
}

.search-loader {
  display: grid;
  min-height: 180px;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.5);
  color: var(--muted);
  font-weight: 800;
}

.search-loader[hidden] {
  display: none !important;
}

.search-result-wrap iframe.loading {
  opacity: 0;
  height: 0;
  min-height: 0;
  pointer-events: none;
}

.reset-progress-button {
  width: 100%;
  margin-top: 14px;
}

.round-button {
  width: 100%;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.48);
  color: var(--ink);
  text-align: left;
}

.round-button.active {
  border-color: rgba(78, 174, 209, 0.55);
  background: rgba(217, 243, 255, 0.82);
}

.round-button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.round-button span,
.round-button small {
  display: block;
}

.round-button span {
  font-weight: 850;
}

.round-button small {
  margin-top: 5px;
  color: var(--muted);
  line-height: 1.35;
}

.notice,
.empty {
  margin: 0;
  padding: 18px;
  border: 1px dashed rgba(78, 174, 209, 0.42);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.45);
  color: var(--muted);
}

.word-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 12px;
}

.word-card {
  position: relative;
  width: 100%;
  min-height: 140px;
  padding: 42px 14px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.5);
  color: var(--ink);
  overflow: hidden;
  text-align: left;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.word-card:hover {
  border-color: rgba(78, 174, 209, 0.55);
  transform: translateY(-2px);
}

.word-card:focus-visible {
  outline: 3px solid rgba(117, 199, 231, 0.4);
  outline-offset: 2px;
}

.word-card.known {
  border-color: rgba(81, 184, 115, 0.48);
  background: linear-gradient(180deg, var(--green-soft), rgba(255, 255, 255, 0.62));
}

.word-card.mastered {
  border-color: rgba(201, 154, 25, 0.52);
  background: linear-gradient(180deg, var(--gold-soft), rgba(255, 255, 255, 0.68));
}

.word-card.wrong {
  border-color: rgba(215, 91, 106, 0.34);
}

.word-card.shasavic-hidden strong {
  display: none;
}

.word-card.shasavic-hidden p {
  margin: 8px 0 14px;
  color: var(--ink);
  font-size: 1.16rem;
  font-weight: 850;
  line-height: 1.35;
  user-select: none;
}

.word-number {
  position: absolute;
  top: 12px;
  left: 12px;
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.word-card strong {
  display: block;
  margin-bottom: 8px;
  font-size: 1.08rem;
  overflow-wrap: anywhere;
}

.word-card p {
  margin-bottom: 12px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.word-card small {
  color: var(--sky-500);
  font-weight: 800;
}

.quiz-card {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.45);
}

.quiz-label {
  margin-bottom: 6px;
  color: var(--sky-500);
  font-size: 0.82rem;
  font-weight: 850;
}

.quiz-card h3 {
  margin-bottom: 16px;
  font-size: clamp(1.6rem, 5vw, 2.35rem);
  overflow-wrap: anywhere;
}

#quizForm {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

input {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--glass-strong);
  color: var(--ink);
  padding: 0 14px;
  outline: none;
}

input:focus {
  border-color: rgba(78, 174, 209, 0.72);
  box-shadow: 0 0 0 4px rgba(117, 199, 231, 0.16);
}

.feedback {
  min-height: 24px;
  margin: 12px 0 0;
  color: var(--muted);
  font-weight: 750;
}

@media (max-width: 860px) {
  .topbar,
  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .stats {
    grid-template-columns: repeat(3, 1fr);
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .sidebar-stack {
    gap: 12px;
  }

  .quiz-panel {
    grid-column: auto;
  }

  .detail-panel {
    grid-column: auto;
  }

  .detail-frame-grid {
    grid-template-columns: 1fr;
  }

  .study-panel {
    grid-template-columns: 1fr;
  }

  .study-panel > .panel-head,
  .study-panel > .start-test-button,
  .study-panel > .notice,
  .study-panel > .word-grid,
  .study-panel > .detail-panel {
    grid-column: 1;
  }

  .study-panel > .start-test-button {
    grid-row: auto;
    order: 6;
  }

  .round-list {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }
}

@media (max-width: 560px) {
  .shell {
    width: min(100% - 20px, 1180px);
    padding: 10px 0;
  }

  .topbar,
  .panel {
    padding: 16px;
  }

  .stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .stats span {
    min-height: 58px;
    padding: 8px 4px;
    font-size: 0.82rem;
  }

  .stats strong {
    font-size: 1.12rem;
  }

  .word-grid {
    grid-template-columns: 1fr;
  }

  #quizForm {
    grid-template-columns: 1fr;
  }

  .primary-button,
  .ghost-button {
    width: 100%;
  }

  .round-title-row > div {
    max-width: calc(100% - 152px);
  }

  .compact-button {
    width: auto;
  }
}
