@import url('https://fonts.googleapis.com/css2?family=ABeeZee:ital@0;1&family=Doulos+SIL&display=swap');

:root {
  --bg: #fff7df;
  --bg-2: #e9f8ff;
  --surface: #ffffff;
  --surface-soft: #fff0bb;
  --surface-blue: #dff4ff;
  --surface-green: #e8ffd9;
  --surface-pink: #ffe5ef;
  --surface-purple: #eee8ff;
  --ink: #28313a;
  --muted: #64707c;
  --line: #e1d7c3;
  --primary: #ffbe3d;
  --primary-dark: #d97d00;
  --accent: #52b5ff;
  --accent-2: #ff7e9f;
  --success: #49c56d;
  --danger: #ff5d5d;
  --warning: #ffdf64;
  --shadow: 0 18px 0 rgba(117, 95, 54, .14), 0 24px 32px rgba(67, 54, 35, .12);
  --shadow-soft: 0 10px 20px rgba(67, 54, 35, .10);
  --shadow-pop: 0 8px 0 rgba(68, 45, 0, .22), 0 14px 24px rgba(68, 45, 0, .15);
  --radius: 28px;
  --radius-sm: 18px;
  --max: 1180px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: 'ABeeZee', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 17px;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 8%, rgba(255, 213, 92, .50), transparent 30%),
    radial-gradient(circle at 92% 10%, rgba(82, 181, 255, .34), transparent 33%),
    radial-gradient(circle at 78% 88%, rgba(255, 126, 159, .22), transparent 34%),
    linear-gradient(135deg, var(--bg), #fffdf4 46%, var(--bg-2));
  min-height: 100vh;
}

.ipa {
  font-family: 'Doulos SIL', 'Gentium Plus', 'Charis SIL', serif;
  letter-spacing: .01em;
}

a { color: inherit; }

img { max-width: 100%; display: block; }

button, input, textarea, select { font: inherit; }

button { cursor: pointer; }

.app-shell { min-height: 100vh; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 14px clamp(18px, 4vw, 46px);
  background: rgba(255, 249, 239, .88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(217, 214, 204, .72);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  font-weight: 800;
  letter-spacing: -.02em;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--primary), #ffe09b);
  box-shadow: var(--shadow);
}

.brand-subtitle { display: block; color: var(--muted); font-size: 12px; font-weight: 500; }

.nav-links {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.nav-links a, .pill-link {
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
}

.nav-links a:hover, .pill-link:hover, .nav-links a.active {
  color: var(--ink);
  background: #fff;
  box-shadow: 0 4px 14px rgba(41, 36, 20, .08);
}

.container {
  width: min(var(--max), calc(100vw - 36px));
  margin: 0 auto;
  padding: 28px 0 54px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(320px, .95fr);
  gap: 26px;
  align-items: stretch;
  min-height: 460px;
}

.hero-card, .card, .panel {
  background: rgba(255, 255, 255, .86);
  border: 1px solid rgba(217, 214, 204, .95);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.hero-card { padding: clamp(26px, 4vw, 46px); }

.hero h1 {
  font-size: clamp(36px, 6vw, 66px);
  line-height: .98;
  margin: 0 0 18px;
  letter-spacing: -.05em;
}

.hero p { color: var(--muted); line-height: 1.7; font-size: 17px; }

.hero-actions, .actions, .button-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 22px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  box-shadow: 0 8px 18px rgba(41, 36, 20, .08);
}

.btn.primary { background: var(--primary); color: #452c00; border-color: rgba(217, 125, 0, .32); }
.btn.secondary { background: var(--surface-blue); }
.btn.success { background: var(--surface-green); }
.btn.ghost { background: transparent; border-color: var(--line); box-shadow: none; }
.btn.danger { background: #ffe3df; color: #8c2d24; }
.btn:disabled { opacity: .48; cursor: not-allowed; }

.grid { display: grid; gap: 18px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.auto { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

.card { padding: 22px; }
.card h2, .card h3, .panel h2, .panel h3 { margin-top: 0; }
.card p, .panel p { color: var(--muted); line-height: 1.65; }

.console-map {
  display: grid;
  gap: 14px;
  align-content: start;
}

.map-node {
  padding: 16px;
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
}

.map-node strong { display: block; margin-bottom: 6px; }

.badge, .chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: #6c4800;
  font-size: 12px;
  text-decoration: none;
}

.chip.blue { background: var(--surface-blue); color: #14566a; }
.chip.green { background: var(--surface-green); color: #245c32; }
.chip.grey { background: #f2f2ef; color: var(--muted); }

.panel { padding: 22px; margin-top: 18px; }

.toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
}

label { display: grid; gap: 7px; color: var(--muted); font-size: 13px; }

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 13px;
  min-height: 42px;
  padding: 10px 12px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

textarea { min-height: 96px; resize: vertical; line-height: 1.45; }

input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(88, 185, 214, .16); }

.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0 22px; }
.tab-btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 10px 14px;
  color: var(--muted);
}
.tab-btn.active { background: var(--primary); color: #442a00; border-color: rgba(217, 125, 0, .42); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.table-wrap { overflow: auto; border-radius: 16px; border: 1px solid var(--line); background: #fff; }
table { width: 100%; border-collapse: collapse; min-width: 860px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid #eeece5; vertical-align: top; }
th { background: #fff8e8; color: #584425; font-size: 13px; position: sticky; top: 0; }
td { color: var(--ink); font-size: 14px; }
tr:last-child td { border-bottom: 0; }

.template-box {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: #2a2d32;
  color: #f5f6f7;
  border-radius: 16px;
  padding: 14px;
  white-space: pre;
  overflow: auto;
  font-size: 12px;
}

.status { min-height: 24px; color: var(--muted); }
.status.ok { color: #24734a; }
.status.error { color: #a03535; }

.learning-layout {
  display: grid;
  grid-template-columns: minmax(260px, 380px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.word-card {
  display: grid;
  grid-template-columns: minmax(250px, .85fr) minmax(300px, 1.15fr);
  gap: 18px;
  align-items: stretch;
}

.picture-box {
  min-height: 380px;
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(255, 184, 77, .18), rgba(88, 185, 214, .15)),
    #fff;
  border: 2px dashed #c9c2b2;
  display: grid;
  place-items: center;
  padding: 18px;
  overflow: hidden;
}

.picture-box img { width: 100%; height: 100%; object-fit: contain; border-radius: 16px; }
.picture-placeholder { color: var(--muted); text-align: center; line-height: 1.6; }

.word-info {
  min-height: 380px;
  display: grid;
  align-content: start;
  gap: 12px;
}

.word-title {
  font-size: clamp(34px, 5vw, 64px);
  line-height: 1;
  margin: 0;
  letter-spacing: -.04em;
}

.meta-list {
  display: grid;
  gap: 10px;
  margin: 10px 0 0;
}

.meta-row {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid #eeeae0;
}

.meta-row span:first-child { color: var(--muted); font-size: 13px; }

.sentence-study-card {
  display: grid;
  gap: 18px;
}

.sentence-picture { min-height: 240px; }
.sentence-text { font-size: clamp(24px, 3.2vw, 42px); text-align: center; margin: 0; }

.exercise-card {
  min-height: 420px;
  display: grid;
  gap: 16px;
  align-content: start;
}

.option-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.option-btn {
  border: 2px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  background: #fff;
  min-height: 74px;
  text-align: left;
}
.option-btn.correct { border-color: var(--success); background: #e8f8ef; }
.option-btn.wrong { border-color: var(--danger); background: #ffeceb; }

.word-bank { display: flex; gap: 10px; flex-wrap: wrap; }
.word-tile {
  padding: 10px 14px;
  border-radius: 13px;
  border: 1px solid var(--line);
  background: #fff;
}

.footer-note { margin-top: 28px; color: var(--muted); font-size: 13px; }

.hide { display: none !important; }

@media (max-width: 920px) {
  .hero, .learning-layout, .word-card, .grid.two, .grid.three { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .meta-row { grid-template-columns: 120px 1fr; }
}

@media (max-width: 620px) {
  .topbar { align-items: start; flex-direction: column; }
  .form-grid, .option-grid { grid-template-columns: 1fr; }
}


/* Kids-friendly oversized 3D UI layer */
.topbar {
  margin: 14px auto 0;
  width: min(var(--max), calc(100vw - 28px));
  border: 3px solid rgba(255,255,255,.92);
  border-radius: 24px;
  box-shadow: var(--shadow-soft);
}

.brand { font-size: 18px; }
.brand-mark {
  width: 54px;
  height: 54px;
  border-radius: 20px;
  font-size: 26px;
  border: 3px solid #fff7d6;
  box-shadow: 0 7px 0 rgba(176, 109, 0, .30), 0 12px 20px rgba(176, 109, 0, .18);
}

.nav-links a, .pill-link {
  min-height: 42px;
  padding: 10px 15px;
  border: 2px solid transparent;
  font-size: 15px;
}

.nav-links a:hover, .pill-link:hover, .nav-links a.active {
  transform: translateY(-1px);
  border-color: #fff;
}

.hero-card, .card, .panel, .map-node {
  border: 3px solid rgba(255,255,255,.96);
  outline: 1px solid rgba(225, 215, 195, .75);
}

.hero-card {
  background: linear-gradient(155deg, rgba(255,255,255,.94), rgba(255,241,192,.88));
}

.card:nth-child(3n+1), .map-node:nth-child(4n+1) { background: linear-gradient(145deg, #ffffff, var(--surface-soft)); }
.card:nth-child(3n+2), .map-node:nth-child(4n+2) { background: linear-gradient(145deg, #ffffff, var(--surface-blue)); }
.card:nth-child(3n+3), .map-node:nth-child(4n+3) { background: linear-gradient(145deg, #ffffff, var(--surface-green)); }
.map-node:nth-child(4n+4) { background: linear-gradient(145deg, #ffffff, var(--surface-pink)); }

.btn, .tab-btn, .option-btn, .word-tile {
  border-width: 3px;
  font-weight: 800;
  letter-spacing: .01em;
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease, border-color .12s ease;
}

.btn {
  min-height: 56px;
  padding: 14px 22px;
  border-radius: 20px;
  box-shadow: var(--shadow-pop);
}

.btn.primary { background: linear-gradient(180deg, #ffd86b, var(--primary)); }
.btn.secondary { background: linear-gradient(180deg, #f3fcff, var(--surface-blue)); color: #174f68; border-color: #b6e2f7; }
.btn.success { background: linear-gradient(180deg, #f6fff0, var(--surface-green)); color: #24633c; border-color: #bbefaa; }
.btn.ghost { background: #fff; border-color: #e9dcc2; box-shadow: 0 6px 0 rgba(117, 95, 54, .12); }
.btn.danger { background: linear-gradient(180deg, #fff1f1, #ffd5d5); color: #8c2d24; border-color: #ffb4b4; }

.btn:hover, .tab-btn:hover, .option-btn:hover, .word-tile:hover { transform: translateY(-2px); }
.btn:active, .tab-btn:active, .option-btn:active, .word-tile:active { transform: translateY(3px); box-shadow: 0 3px 0 rgba(68, 45, 0, .18); }

.badge, .chip {
  min-height: 30px;
  padding: 7px 12px;
  border: 2px solid rgba(255,255,255,.90);
  font-weight: 800;
  box-shadow: 0 4px 0 rgba(117, 95, 54, .10);
}

.picture-box {
  min-height: 420px;
  border: 4px solid #fff;
  outline: 3px dashed rgba(82,181,255,.45);
  box-shadow: inset 0 0 0 8px rgba(255,255,255,.52), var(--shadow);
}

.word-info {
  min-height: 420px;
  border-radius: var(--radius);
  padding: 24px;
  background: linear-gradient(145deg, #fff, #fff4cd);
  box-shadow: var(--shadow-soft);
}

.word-title {
  font-size: clamp(48px, 7vw, 88px);
  text-shadow: 0 5px 0 rgba(255, 205, 113, .42);
}

.meta-row {
  grid-template-columns: 170px minmax(0, 1fr);
  padding: 14px 0;
  font-size: 18px;
}
.meta-row span:first-child { font-size: 14px; font-weight: 800; color: #7a6332; }

.exercise-card {
  min-height: 520px;
  padding: clamp(22px, 4vw, 36px);
  background: linear-gradient(160deg, #ffffff, #fff7db 54%, #eaf8ff);
}

.exercise-card h2 {
  font-size: clamp(30px, 4vw, 52px);
  line-height: 1.1;
  margin: 14px 0 20px;
}

.option-grid {
  gap: 18px;
}

.option-btn {
  min-height: 104px;
  padding: 22px;
  border-radius: 26px;
  background: linear-gradient(180deg, #fff, #fff8e8);
  box-shadow: 0 9px 0 rgba(117, 95, 54, .16), 0 16px 24px rgba(67,54,35,.10);
  text-align: center;
  font-size: clamp(20px, 2.2vw, 30px);
}

.option-btn.correct {
  color: #155b31;
  border-color: #36be66;
  background: linear-gradient(180deg, #f3fff5, #c9ffd6);
  animation: pop-correct .28s ease both;
}

.option-btn.wrong {
  color: #8a1f1f;
  border-color: #ff6868;
  background: linear-gradient(180deg, #fff4f4, #ffdada);
  animation: shake-wrong .26s ease both;
}

.status {
  min-height: 54px;
  display: grid;
  align-items: center;
  margin-top: 12px;
  padding: 0 2px;
}

.status.ok, .status.error {
  border-radius: 24px;
  padding: 16px 20px;
  border: 3px solid #fff;
  box-shadow: var(--shadow-soft);
  font-size: clamp(20px, 2.2vw, 30px);
  font-weight: 900;
  text-align: center;
}

.status.ok {
  color: #14552f;
  background: linear-gradient(180deg, #f3fff5, #c9ffd6);
  animation: feedback-pop .32s ease both;
}

.status.error {
  color: #8a1f1f;
  background: linear-gradient(180deg, #fff7e9, #ffdada);
  animation: feedback-shake .30s ease both;
}

.word-tile {
  padding: 16px 20px;
  border-radius: 18px;
  background: linear-gradient(180deg, #fff, #f1fbff);
  box-shadow: 0 5px 0 rgba(82, 181, 255, .22);
  font-size: 20px;
}

input, select, textarea {
  min-height: 54px;
  border-radius: 18px;
  border-width: 2px;
  font-size: 16px;
}

textarea { min-height: 126px; }

.ipa {
  font-family: 'Doulos SIL', 'Gentium Plus', 'Charis SIL', serif;
  font-size: 1.12em;
  color: #394456;
}

@keyframes pop-correct {
  0% { transform: scale(.98); }
  60% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

@keyframes shake-wrong {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

@keyframes feedback-pop {
  0% { transform: translateY(8px) scale(.96); opacity: 0; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}

@keyframes feedback-shake {
  0% { transform: translateX(0); opacity: 0; }
  25% { transform: translateX(-5px); opacity: 1; }
  50% { transform: translateX(5px); }
  75% { transform: translateX(-3px); }
  100% { transform: translateX(0); }
}
