:root {
  --bg: #f6efe5;
  --bg-deep: #ead9c5;
  --surface: rgba(255, 252, 247, 0.88);
  --surface-strong: rgba(255, 252, 247, 0.96);
  --text: #1f160f;
  --muted: #6c5b4c;
  --accent: #df7a2f;
  --accent-deep: #8f4310;
  --border: rgba(31, 22, 15, 0.08);
  --shadow: 0 22px 60px rgba(84, 52, 26, 0.14);
  --font-family: "Outfit", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden],
.screen {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.92), transparent 28%),
    radial-gradient(circle at bottom right, rgba(223, 122, 47, 0.18), transparent 24%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-deep) 100%);
  font-family: var(--font-family);
}

body.modal-open {
  overflow: hidden;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.account-bar {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 10px 8px 16px;
  background: var(--surface-strong);
  color: var(--muted);
  box-shadow: 0 14px 34px rgba(84, 52, 26, 0.14);
  font-weight: 800;
}

.account-bar .back-link {
  min-height: 36px;
}

.page-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 18px;
}

.hero-card {
  width: min(100%, 920px);
  min-height: min(780px, calc(100vh - 36px));
  border: 1px solid var(--border);
  border-radius: 34px;
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.92), rgba(255, 249, 241, 0.74)),
    linear-gradient(135deg, rgba(223, 122, 47, 0.12), rgba(255, 255, 255, 0));
  box-shadow: var(--shadow);
}

.screen.is-active {
  display: block !important;
  padding: clamp(28px, 5vw, 56px);
}

.screen.is-active[data-screen="home"],
.screen.is-active[data-screen="login"] {
  display: grid !important;
  align-content: center;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

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

h1 {
  max-width: 11ch;
  margin-bottom: 0;
  font-size: clamp(2.8rem, 8vw, 5.8rem);
  line-height: 0.94;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(2.2rem, 5vw, 4.2rem);
  line-height: 1;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 0;
  font-size: 1.25rem;
}

.intro-copy {
  max-width: 42ch;
  margin: 20px 0 0;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.65;
}

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

.subject-option-grid {
  margin-top: clamp(40px, 8vw, 92px);
}

.word-option-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 24px;
}

.primary-button,
.secondary-button,
.back-link,
.delete-button {
  min-height: 56px;
  border-radius: 18px;
  font-weight: 800;
  transition:
    transform 180ms ease,
    box-shadow 180ms ease,
    background 180ms ease;
}

.primary-button,
.secondary-button,
.delete-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  padding: 0 22px;
}

.primary-button,
.secondary-button,
.back-link,
.delete-button {
  border-color: rgba(143, 67, 16, 0.16);
  background: var(--surface-strong);
  color: var(--accent-deep);
  box-shadow: 0 14px 30px rgba(84, 52, 26, 0.1);
}

.primary-button:hover,
.secondary-button:hover,
.back-link:hover,
.delete-button:hover {
  transform: translateY(-1px);
}

.primary-button:disabled,
.secondary-button:disabled,
.delete-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  transform: none;
}

.compact {
  min-height: 52px;
  white-space: nowrap;
}

.back-link {
  min-height: 44px;
  border: 1px solid transparent;
  padding: 0 16px;
  text-decoration: none;
}

.screen-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 32px;
}

.screen-header .back-link {
  order: 2;
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: end;
  margin-bottom: 24px;
}

.login-form {
  display: grid;
  max-width: 520px;
  gap: 18px;
  margin-top: 34px;
}

.field {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 800;
}

.field input {
  width: 100%;
  min-height: 56px;
  border: 1px solid rgba(31, 22, 15, 0.1);
  border-radius: 18px;
  padding: 0 18px;
  background: var(--surface-strong);
  color: var(--text);
  outline: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.78);
}

.field input:focus {
  border-color: rgba(223, 122, 47, 0.65);
  box-shadow: 0 0 0 4px rgba(223, 122, 47, 0.13);
}

.status-banner {
  min-height: 24px;
  margin: 0;
  font-weight: 800;
}

.status-banner.muted {
  color: var(--muted);
}

.status-banner.error {
  color: #8f1c1c;
}

.status-banner.success {
  color: #237348;
}

.subject-list,
.time-log {
  display: grid;
  gap: 12px;
}

.subject-card,
.log-item,
.empty-state {
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: 0 12px 30px rgba(84, 52, 26, 0.08);
}

.subject-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  width: 100%;
  min-height: 84px;
  padding: 18px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition:
    transform 180ms ease,
    box-shadow 180ms ease,
    border-color 180ms ease;
}

.subject-card:hover,
.subject-card:focus-visible {
  border-color: rgba(223, 122, 47, 0.42);
  box-shadow: 0 18px 38px rgba(84, 52, 26, 0.14);
  transform: translateY(-1px);
  outline: none;
}

.subject-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.subject-card strong,
.subject-card span {
  display: block;
}

.log-item span,
.empty-state {
  color: var(--muted);
}

.subject-card .total-pill,
.total-pill {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 0 12px;
  background: rgba(223, 122, 47, 0.12);
  color: var(--accent-deep);
  font-size: 0.9rem;
  font-weight: 800;
  white-space: nowrap;
}

.timer-panel {
  display: grid;
  gap: 18px;
  justify-items: center;
  border: 1px solid var(--border);
  border-radius: 28px;
  padding: clamp(24px, 5vw, 44px);
  background: var(--surface-strong);
  box-shadow: 0 18px 44px rgba(84, 52, 26, 0.12);
}

body.timer-fullscreen {
  overflow: hidden;
}

body.timer-fullscreen .account-bar {
  display: none;
}

body.timer-fullscreen .screen.is-active[data-screen="subject-timer"] {
  display: block !important;
  width: 100vw;
  min-height: 100vh;
  border: 0;
  border-radius: 0;
  padding: 0;
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.92), transparent 28%),
    radial-gradient(circle at bottom right, rgba(223, 122, 47, 0.2), transparent 24%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-deep) 100%);
  box-shadow: none;
}

body.timer-fullscreen .screen.is-active[data-screen="subject-timer"] .screen-header,
body.timer-fullscreen .screen.is-active[data-screen="subject-timer"] .log-section {
  display: none;
}

body.timer-fullscreen .timer-panel {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  align-content: center;
  justify-items: center;
  border: 0;
  border-radius: 0;
  padding: clamp(28px, 6vw, 72px);
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.9), rgba(255, 249, 241, 0.76)),
    linear-gradient(135deg, rgba(223, 122, 47, 0.16), rgba(255, 255, 255, 0));
  box-shadow: none;
}

body.timer-fullscreen .timer-status {
  align-self: end;
  font-size: clamp(1.1rem, 2.4vw, 1.7rem);
}

body.timer-fullscreen #timer-display {
  align-self: center;
  font-size: clamp(3.2rem, 12vw, 9rem);
}

body.timer-fullscreen .timer-ring {
  align-self: center;
  width: min(82vw, 82vh, 760px);
}

body.timer-fullscreen .timer-ring-track,
body.timer-fullscreen .timer-ring-progress {
  stroke-width: 3.5;
}

body.timer-fullscreen .timer-actions {
  align-self: end;
  padding-bottom: clamp(8px, 3vh, 32px);
}

body.timer-fullscreen .timer-actions button {
  min-width: min(190px, 28vw);
}

.timer-status {
  margin-bottom: 0;
  color: var(--muted);
  font-weight: 800;
}

#timer-display {
  font-size: clamp(3rem, 12vw, 7rem);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.timer-ring {
  position: relative;
  display: grid;
  width: min(100%, 420px);
  aspect-ratio: 1;
  place-items: center;
}

.timer-ring svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.timer-ring-track,
.timer-ring-progress {
  fill: none;
  stroke-width: 5;
}

.timer-ring-track {
  stroke: rgba(143, 67, 16, 0.1);
}

.timer-ring-progress {
  stroke: var(--accent);
  stroke-linecap: round;
  stroke-dasharray: 86 339.292;
  transform-origin: 60px 60px;
  transform: rotate(-90deg);
}

.timer-ring.is-spinning .timer-ring-progress {
  animation: timer-spin 2.2s linear infinite;
}

.timer-ring.is-paused .timer-ring-progress {
  animation-play-state: paused;
}

@keyframes timer-spin {
  from {
    transform: rotate(-90deg);
  }

  to {
    transform: rotate(270deg);
  }
}

.timer-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

.log-section {
  margin-top: 28px;
}

.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
}

.selected-date-heading {
  margin-top: 24px;
}

.calendar-toolbar {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 48px;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}

.calendar-title {
  text-align: center;
  font-size: clamp(1.1rem, 3vw, 1.5rem);
}

.calendar-nav-button {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border: 1px solid rgba(143, 67, 16, 0.16);
  border-radius: 16px;
  background: var(--surface-strong);
  color: var(--accent-deep);
  box-shadow: 0 10px 24px rgba(84, 52, 26, 0.09);
  font-size: 1.5rem;
  font-weight: 800;
}

.learning-calendar {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
  touch-action: pan-y;
  user-select: none;
}

.calendar-weekday {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-align: center;
}

.calendar-day {
  display: grid;
  min-height: 76px;
  align-content: space-between;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 10px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
  box-shadow: 0 10px 24px rgba(84, 52, 26, 0.08);
}

.calendar-day:hover,
.calendar-day.is-selected {
  border-color: rgba(223, 122, 47, 0.56);
  background: var(--surface-strong);
}

.calendar-day.blank {
  visibility: hidden;
}

.calendar-day.has-logs {
  background: rgba(223, 122, 47, 0.12);
}

.calendar-day-number {
  font-weight: 800;
}

.calendar-day-marker {
  overflow: hidden;
  color: var(--accent-deep);
  font-size: 0.78rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.log-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
}

.log-item-main {
  display: grid;
  gap: 4px;
}

.log-item strong {
  font-size: 1.05rem;
}

.delete-button {
  min-height: 42px;
  padding: 0 14px;
}

.empty-state {
  padding: 18px;
}

.word-result {
  display: grid;
  gap: 12px;
}

.word-list {
  display: grid;
  gap: 12px;
  margin-bottom: 20px;
}

.word-list-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 14px;
  background: var(--surface);
  box-shadow: 0 12px 30px rgba(84, 52, 26, 0.08);
  cursor: pointer;
  transition:
    transform 180ms ease,
    box-shadow 180ms ease,
    border-color 180ms ease;
}

.word-list-item:hover,
.word-list-item:focus-visible {
  border-color: rgba(223, 122, 47, 0.42);
  box-shadow: 0 18px 38px rgba(84, 52, 26, 0.14);
  transform: translateY(-1px);
  outline: none;
}

.word-chip {
  color: var(--text);
  font-size: 1.15rem;
  font-weight: 800;
}

.word-card {
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 22px;
  background: var(--surface);
  box-shadow: 0 12px 30px rgba(84, 52, 26, 0.08);
}

.word-card h3 {
  margin-bottom: 14px;
  font-size: clamp(1.8rem, 4vw, 3rem);
}

.word-card p:not(.eyebrow) {
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.6;
}

.quiz-actions {
  margin-bottom: 18px;
}

.quiz-option-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.quiz-meaning-button {
  min-height: 96px;
  height: auto;
  align-items: flex-start;
  padding-block: 16px;
  text-align: left;
  white-space: normal;
}

.quiz-meaning-button.is-correct {
  border-color: rgba(20, 89, 52, 0.7);
  background: #237348;
  color: #ffffff;
  box-shadow: 0 16px 34px rgba(20, 89, 52, 0.28);
}

.quiz-meaning-button.is-incorrect {
  border-color: rgba(122, 23, 23, 0.72);
  background: #9f2424;
  color: #ffffff;
  box-shadow: 0 16px 34px rgba(122, 23, 23, 0.26);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(31, 22, 15, 0.38);
  backdrop-filter: blur(8px);
}

.modal-panel {
  position: relative;
  width: min(620px, 100%);
  max-height: min(760px, calc(100vh - 40px));
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 22px;
  background: var(--surface-strong);
  box-shadow: 0 24px 70px rgba(31, 22, 15, 0.24);
}

.modal-close {
  position: sticky;
  top: 0;
  left: 100%;
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid rgba(143, 67, 16, 0.16);
  border-radius: 50%;
  background: var(--surface-strong);
  color: var(--accent-deep);
  box-shadow: 0 10px 24px rgba(84, 52, 26, 0.12);
  font-size: 1.6rem;
  font-weight: 800;
}

@media (max-width: 720px) {
  .page-shell {
    padding: 8px;
  }

  .hero-card {
    min-height: calc(100vh - 16px);
    border-radius: 26px;
  }

  .option-grid,
  .inline-form {
    grid-template-columns: 1fr;
  }

  .screen-header {
    flex-direction: column;
  }

  .screen-header .back-link {
    order: 0;
  }

  .subject-card,
  .log-item {
    grid-template-columns: 1fr;
  }

  .subject-actions {
    justify-content: flex-start;
  }

  .learning-calendar {
    gap: 5px;
  }

  .calendar-day {
    min-height: 58px;
    border-radius: 12px;
    padding: 7px;
  }

  .calendar-day-marker {
    font-size: 0.68rem;
  }

  .word-list-item {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .quiz-option-grid {
    grid-template-columns: 1fr;
  }

  .log-item {
    align-items: flex-start;
    flex-direction: column;
  }

  body.timer-fullscreen .timer-actions button {
    width: 100%;
    min-width: 0;
  }
}
