:root {
  color-scheme: light;
  --ink: #1d2b26;
  --muted: #5f6d67;
  --paper: #f6f3ee;
  --panel: #fffdf9;
  --line: #dfe5df;
  --green: #1f5b46;
  --green-deep: #183f31;
  --green-pale: #e8f3ee;
  --yellow: #e8c76a;
  --red-pale: #f7e6e1;
  --blue-pale: #eaf2fa;
  --shadow: rgba(18, 32, 28, 0.08);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background: linear-gradient(180deg, #f7f4ef 0%, #f5f1ea 100%);
  font-family: 'DM Sans', sans-serif;
}
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .18;
  background-image: radial-gradient(#cfc9c0 0.7px, transparent 0.7px);
  background-size: 14px 14px;
}
.shell {
  position: relative;
  max-width: 1040px;
  min-height: 100vh;
  margin: auto;
  padding: 34px 34px 24px;
  display: flex;
  flex-direction: column;
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand {
  color: var(--ink);
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -.5px;
  text-decoration: none;
}
.brand span { color: var(--green); font-weight: 500; }
.streak {
  color: var(--muted);
  font-size: 13px;
  letter-spacing: .02em;
}
.streak-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--yellow);
  box-shadow: 0 0 0 4px rgba(232, 199, 106, 0.2);
}
.login-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 48px;
  align-items: center;
  margin-bottom: 0;
}
.login-auth-panel {
  margin: 0;
}
.intro {
  margin: 11vh 0 38px;
  max-width: 580px;
}
.eyebrow {
  margin: 0 0 20px;
  color: var(--green);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.8px;
  text-transform: uppercase;
}
h1 {
  margin: 0;
  font-family: Fraunces, Georgia, serif;
  font-size: clamp(46px, 7vw, 82px);
  font-weight: 600;
  line-height: .98;
  letter-spacing: -2px;
}
h1 em {
  color: var(--green);
  font-style: normal;
}
.subhead {
  max-width: 420px;
  margin: 24px 0 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.7;
}
.top-tabs {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 0 auto 18px;
  width: min(100%, 680px);
}
.tab {
  padding: 10px 16px;
  background: rgba(255,255,255,0.25);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}
.tab:hover {
  border-color: rgba(31, 91, 70, 0.35);
  color: var(--ink);
}
.tab.active {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
  box-shadow: 0 8px 18px rgba(31, 91, 70, 0.18);
}
.utility-panel {
  width: min(100%, 680px);
  margin: 0 auto 20px;
}
.review-panel {
  width: min(100%, 680px);
  min-height: 320px;
  margin: 0 auto;
  padding: 25px 30px 30px;
  background: rgba(255,255,255,0.62);
  border: 1px solid var(--line);
  box-shadow: 0 18px 45px var(--shadow);
  border-radius: 18px;
}
.panel-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.4px;
  text-transform: uppercase;
}
.session-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0 0;
}
.session-field {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.session-field select {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 500;
  letter-spacing: normal;
  text-transform: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.session-field select:focus,
.auth-form input:focus,
.add-word-grid input:focus,
.add-word-grid textarea:focus {
  outline: none;
  border-color: rgba(31, 91, 70, 0.45);
  box-shadow: 0 0 0 3px rgba(31, 91, 70, 0.08);
}
#card {
  position: relative;
  margin-top: 28px;
  padding: 54px 20px 22px;
  border: 2px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255,255,255,.92), rgba(249,244,238,.95));
  box-shadow: 0 14px 34px rgba(38, 49, 44, .05);
  text-align: center;
}
.word-card {
  min-height: 280px;
}
h2 {
  margin: 0 0 18px;
  font-family: Fraunces, Georgia, serif;
  font-size: clamp(35px, 5vw, 54px);
  font-weight: 600;
  letter-spacing: -.8px;
}
.word-definition-box {
  display: grid;
  gap: 12px;
}
.definition {
  margin: 0 auto;
  font-size: 21px;
  line-height: 1.45;
}
.example {
  max-width: 480px;
  margin: 0 auto;
  color: var(--muted);
  font-family: Fraunces, Georgia, serif;
  font-size: 16px;
  line-height: 1.6;
}
.show-answer-btn {
  position: absolute;
  left: 16px;
  bottom: 16px;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.corner-choice {
  position: absolute;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 96px;
  min-height: 46px;
  padding: 8px;
  border: 1px solid rgba(38,49,44,.12);
  border-radius: 12px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.corner-choice:hover, .show-answer-btn:hover {
  transform: translateY(-1px);
}
.corner-choice.easy {
  top: 12px;
  left: 12px;
  background: var(--green-pale);
  color: var(--green);
}
.corner-choice.hard {
  right: 12px;
  bottom: 12px;
  background: var(--red-pale);
  color: #8c3f2d;
}
.auth-panel {
  margin: 20px 0 0;
  padding: 18px 18px 14px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.6);
  border-radius: 14px;
}
.auth-panel h3 {
  margin: 0 0 12px;
  font-size: 18px;
}
.auth-form {
  display: grid;
  gap: 10px;
}
.auth-form input {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
  background: #fff;
}
.auth-actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}
.auth-actions button, .ghost {
  padding: 11px 14px;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  font: inherit;
  transition: transform 0.15s ease, opacity 0.15s ease;
}
.auth-actions button:hover, .ghost:hover {
  transform: translateY(-1px);
}
.primary {
  background: var(--green);
  color: #fff;
}
.secondary {
  background: var(--green-pale);
  color: var(--green);
}
.ghost {
  background: transparent;
  border: 1px solid var(--line);
}
.auth-message {
  margin: 12px 0 0;
  font-size: 13px;
}
.word-panel { display: none; }
.word-panel.is-visible { display: block; }
.add-word-form {
  margin: 18px 0 0;
  padding: 18px 16px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.72);
  border-radius: 14px;
}
.public-word-form { margin-top: 18px; }
.add-word-header h3 {
  margin: 0 0 14px;
  font-size: 18px;
}
.library-count {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}
.add-word-grid {
  display: grid;
  gap: 10px;
}
.add-word-grid input, .add-word-grid textarea {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
  resize: vertical;
  background: #fff;
}
.add-word-actions { margin-top: 12px; }
.add-word-status { margin: 12px 0 0; font-size: 13px; }
.add-word-status.success { color: var(--green); }
.add-word-status.error { color: #a04e43; }
.loading, .empty, .error {
  padding: 76px 0;
  color: var(--muted);
  text-align: center;
}
.empty strong {
  display: block;
  margin-bottom: 8px;
  color: var(--ink);
  font-family: Fraunces, Georgia, serif;
  font-size: 27px;
}
.error { color: #a04e43; }
footer {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  margin-top: auto;
  padding-top: 70px;
  color: var(--muted);
  font-size: 12px;
}
@media (max-width: 600px) {
  .shell { padding: 24px 18px; }
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }
  .login-layout {
    grid-template-columns: 1fr;
    gap: 32px;
  }
  .intro { margin: 9vh 0 32px; }
  .review-panel {
    padding: 20px 16px;
    border-radius: 16px;
  }
  .session-controls {
    grid-template-columns: 1fr;
  }
  #card {
    padding: 44px 14px 18px;
    min-height: 240px;
  }
  .show-answer-btn {
    left: 12px;
    bottom: 12px;
    padding: 10px 12px;
  }
  .corner-choice {
    width: 80px;
  }
  footer {
    display: block;
    line-height: 2;
    padding-top: 52px;
  }
  footer span { display: block; }
}
