:root {
  color-scheme: light;
  --background: #f5f5f7;
  --surface: rgba(255, 255, 255, 0.92);
  --surface-solid: #ffffff;
  --surface-muted: #f2f2f7;
  --text: #1d1d1f;
  --secondary: #6e6e73;
  --tertiary: #8e8e93;
  --separator: rgba(60, 60, 67, 0.12);
  --accent: #007aff;
  --accent-soft: rgba(0, 122, 255, 0.1);
  --danger: #ff3b30;
  --gold: #ffb000;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.055);
  --radius-large: 22px;
  --radius-medium: 16px;
  --sidebar-width: 248px;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--background);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--background);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
}

button,
input,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button {
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(0, 122, 255, 0.25);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

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

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  display: flex;
  width: var(--sidebar-width);
  flex-direction: column;
  padding: 28px 18px;
  border-right: 1px solid var(--separator);
  background: rgba(248, 248, 250, 0.84);
  backdrop-filter: saturate(180%) blur(24px);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 10px 30px;
}

.brand-mark,
.mobile-brand-mark {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: var(--accent);
  color: #ffffff;
  font-size: 21px;
  font-weight: 750;
  box-shadow: 0 7px 18px rgba(0, 122, 255, 0.25);
}

.brand-name {
  font-size: 17px;
  font-weight: 720;
}

.brand-caption {
  margin-top: 3px;
  color: var(--secondary);
  font-size: 12px;
}

.side-nav {
  display: grid;
  gap: 5px;
}

.nav-item {
  display: flex;
  width: 100%;
  min-height: 46px;
  align-items: center;
  gap: 12px;
  border-radius: 11px;
  background: transparent;
  color: #3a3a3c;
  padding: 0 13px;
  text-align: left;
  transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.nav-item:hover {
  background: rgba(118, 118, 128, 0.08);
}

.nav-item:active {
  transform: scale(0.985);
}

.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 650;
}

.nav-glyph {
  width: 24px;
  color: var(--tertiary);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.nav-item.active .nav-glyph {
  color: var(--accent);
}

.sidebar-note {
  display: grid;
  gap: 7px;
  margin-top: auto;
  padding: 16px 13px 4px;
  color: var(--secondary);
}

.sidebar-note span {
  color: var(--text);
  font-size: 13px;
  font-weight: 650;
}

.sidebar-note small {
  font-size: 12px;
  line-height: 1.45;
}

.account-button,
.mobile-account-button {
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 680;
}

.account-button {
  width: fit-content;
  min-height: 34px;
  margin-top: 6px;
  padding: 0 12px;
}

.mobile-account-button {
  min-height: 34px;
  padding: 0 10px;
}

.main-content {
  min-height: 100vh;
  margin-left: var(--sidebar-width);
}

.mobile-header,
.bottom-nav {
  display: none;
}

.view {
  width: min(100%, 850px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 64px 38px 96px;
  animation: view-enter 220ms ease both;
}

@keyframes view-enter {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(34px, 5vw, 48px);
  font-weight: 760;
  line-height: 1.08;
}

.eyebrow,
.section-label,
.preview-kicker {
  color: var(--secondary);
  font-size: 12px;
  font-weight: 680;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.surface,
.surface-quiet {
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.start-state {
  display: grid;
  min-height: calc(100vh - 160px);
  align-content: center;
  gap: 30px;
  width: min(100%, 680px);
  margin: 0 auto;
}

.start-copy p,
.page-heading p {
  max-width: 590px;
  margin: 16px 0 0;
  color: var(--secondary);
  font-size: 17px;
  line-height: 1.55;
}

.start-copy .eyebrow {
  margin-bottom: 13px;
}

.start-preview {
  border-radius: var(--radius-large);
  padding: 24px;
}

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 17px;
  border-bottom: 1px solid var(--separator);
}

.preview-time {
  color: var(--tertiary);
  font-size: 13px;
}

.preview-steps {
  display: grid;
  gap: 19px;
  margin: 22px 0 0;
  padding: 0;
  list-style: none;
}

.preview-steps li {
  display: grid;
  grid-template-columns: 34px 1fr;
  align-items: start;
  gap: 14px;
}

.preview-steps li > span {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  font-weight: 720;
}

.preview-steps strong,
.preview-steps small {
  display: block;
}

.preview-steps strong {
  font-size: 15px;
}

.preview-steps small {
  margin-top: 4px;
  color: var(--secondary);
  font-size: 14px;
  line-height: 1.45;
}

.primary-button,
.secondary-button,
.quiet-button {
  min-height: 48px;
  border-radius: 13px;
  padding: 0 20px;
  font-size: 15px;
  font-weight: 670;
  transition: transform 140ms ease, filter 140ms ease, background 140ms ease;
}

.primary-button {
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 9px 24px rgba(0, 122, 255, 0.2);
}

.primary-button:hover {
  filter: brightness(1.04);
}

.primary-button:active,
.secondary-button:active,
.quiet-button:active {
  transform: scale(0.985);
}

.secondary-button {
  background: var(--surface-muted);
  color: var(--text);
}

.quiet-button {
  min-height: 40px;
  background: transparent;
  color: var(--accent);
  padding: 0 8px;
}

.large-button,
.save-button {
  width: 100%;
  min-height: 54px;
}

.exercise-state {
  display: grid;
  gap: 22px;
}

.exercise-toolbar,
.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
}

.exercise-toolbar .eyebrow,
.page-heading .eyebrow {
  margin-bottom: 11px;
}

.timer-card {
  display: grid;
  flex: 0 0 auto;
  min-width: 116px;
  gap: 4px;
  border-radius: var(--radius-medium);
  background: var(--surface-solid);
  padding: 14px 17px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.045);
  text-align: right;
}

.timer-card span {
  color: var(--tertiary);
  font-size: 11px;
}

.timer-card strong {
  font-size: 24px;
  font-variant-numeric: tabular-nums;
}

.timer-card.is-floating {
  position: fixed;
  top: 28px;
  right: 32px;
  z-index: 30;
  border: 1px solid rgba(0, 122, 255, 0.18);
  box-shadow: 0 14px 36px rgba(0, 122, 255, 0.16);
}

.task-card,
.editor-section,
.feedback-section {
  border-radius: var(--radius-large);
  padding: 25px;
}

.task-card-heading,
.rating-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.category-pill {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  border-radius: 15px;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 0 12px;
  font-size: 12px;
  font-weight: 680;
}

.definition {
  margin: 22px 0 0;
  font-size: 20px;
  font-weight: 620;
  line-height: 1.5;
}

.task-prompts {
  display: grid;
  gap: 12px;
  margin-top: 22px;
}

.task-prompt {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 14px;
  border-radius: var(--radius-medium);
  background: var(--surface-muted);
  padding: 18px;
}

.task-number {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 50%;
  background: #ffffff;
  color: var(--accent);
  font-size: 13px;
  font-weight: 720;
}

.task-prompt strong {
  display: block;
  margin-bottom: 5px;
  font-size: 15px;
}

.task-prompt p {
  margin: 0;
  color: var(--secondary);
  font-size: 14px;
  line-height: 1.55;
}

.mastery-panel {
  margin-top: 24px;
  padding-top: 22px;
  border-top: 1px solid var(--separator);
}

.mastery-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.mastery-option {
  display: flex;
  min-height: 42px;
  align-items: center;
  gap: 11px;
  border-radius: 11px;
  background: transparent;
  color: var(--text);
  padding: 0 8px;
  text-align: left;
}

.mastery-check {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border: 1px solid rgba(60, 60, 67, 0.18);
  border-radius: 50%;
  background: #ffffff;
  color: transparent;
  font-size: 13px;
  font-weight: 750;
}

.mastery-option.checked .mastery-check {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.timer-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 24px;
}

.editor-section label {
  display: block;
  font-size: 17px;
  font-weight: 700;
}

.editor-section > p {
  margin: 7px 0 17px;
  color: var(--secondary);
  font-size: 13px;
  line-height: 1.45;
}

textarea,
.search-field input {
  width: 100%;
  border: 0;
  background: var(--surface-muted);
  color: var(--text);
}

textarea {
  display: block;
  min-height: 140px;
  resize: vertical;
  border-radius: 14px;
  padding: 15px 16px;
  font-size: 15px;
  line-height: 1.55;
}

textarea::placeholder,
input::placeholder {
  color: #9a9aa0;
}

.rating-header {
  margin: 12px 0 18px;
}

.star-rating {
  display: flex;
  gap: 6px;
}

.star-button {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 10px;
  background: var(--surface-muted);
  color: #c7c7cc;
  font-size: 23px;
  transition: transform 140ms ease, color 140ms ease, background 140ms ease;
}

.star-button.selected {
  background: rgba(255, 176, 0, 0.12);
  color: var(--gold);
}

.star-button:hover {
  transform: scale(1.04);
}

#rating-caption {
  color: var(--secondary);
  font-size: 13px;
}

.page-heading {
  margin-bottom: 30px;
}

.search-field {
  width: 220px;
  flex: 0 0 auto;
}

.search-field input {
  height: 44px;
  border-radius: 12px;
  padding: 0 15px;
}

.category-list,
.history-list {
  display: grid;
  gap: 14px;
}

.category-group {
  overflow: hidden;
  border-radius: var(--radius-medium);
  background: var(--surface-solid);
  box-shadow: 0 9px 30px rgba(0, 0, 0, 0.035);
}

.category-toggle {
  display: flex;
  width: 100%;
  min-height: 72px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  background: transparent;
  color: var(--text);
  padding: 0 21px;
  text-align: left;
}

.category-toggle strong,
.category-toggle small {
  display: block;
}

.category-toggle strong {
  font-size: 16px;
}

.category-toggle small {
  margin-top: 4px;
  color: var(--tertiary);
  font-size: 12px;
}

.disclosure {
  color: var(--tertiary);
  font-size: 18px;
  transition: transform 180ms ease;
}

.category-group.expanded .disclosure {
  transform: rotate(90deg);
}

.topic-list {
  border-top: 1px solid var(--separator);
}

.topic-row {
  display: grid;
  width: 100%;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 18px;
  background: transparent;
  color: var(--text);
  padding: 17px 21px;
  text-align: left;
}

.topic-row + .topic-row {
  border-top: 1px solid var(--separator);
}

.topic-row:hover {
  background: rgba(118, 118, 128, 0.055);
}

.topic-row strong,
.topic-row small {
  display: block;
}

.topic-row strong {
  font-size: 15px;
}

.topic-row small {
  margin-top: 5px;
  color: var(--secondary);
  font-size: 13px;
  line-height: 1.45;
}

.topic-action {
  color: var(--accent);
  font-size: 13px;
  font-weight: 650;
}

.history-stat {
  display: grid;
  min-width: 92px;
  border-radius: 15px;
  padding: 12px 16px;
  text-align: right;
}

.history-stat strong {
  font-size: 24px;
}

.history-stat span {
  color: var(--tertiary);
  font-size: 11px;
}

.history-card {
  position: relative;
  border-radius: var(--radius-large);
  background: var(--surface-solid);
  padding: 22px;
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.04);
}

.history-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.history-card h2 {
  margin: 0;
  font-size: 19px;
}

.history-meta {
  margin-top: 6px;
  color: var(--tertiary);
  font-size: 12px;
}

.history-rating {
  color: var(--gold);
  font-size: 14px;
  white-space: nowrap;
}

.delete-button {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 10px;
  background: rgba(255, 59, 48, 0.09);
  color: var(--danger);
  font-size: 15px;
}

.history-section {
  margin-top: 17px;
  padding-top: 16px;
  border-top: 1px solid var(--separator);
}

.history-section strong {
  display: block;
  margin-bottom: 6px;
  color: var(--secondary);
  font-size: 12px;
}

.history-section p {
  margin: 0;
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.empty-state {
  display: grid;
  min-height: 250px;
  place-items: center;
  border-radius: var(--radius-large);
  background: var(--surface-solid);
  color: var(--secondary);
  padding: 32px;
  text-align: center;
}

.empty-state strong {
  display: block;
  margin-bottom: 8px;
  color: var(--text);
  font-size: 18px;
}

.empty-state p {
  max-width: 360px;
  margin: 0;
  font-size: 14px;
  line-height: 1.55;
}

.toast {
  position: fixed;
  z-index: 100;
  left: 50%;
  bottom: 30px;
  transform: translate(-50%, 20px);
  border-radius: 12px;
  background: rgba(29, 29, 31, 0.9);
  color: #ffffff;
  padding: 11px 16px;
  opacity: 0;
  pointer-events: none;
  font-size: 13px;
  transition: opacity 180ms ease, transform 180ms ease;
  backdrop-filter: blur(18px);
}

.toast.visible {
  transform: translate(-50%, 0);
  opacity: 1;
}

.auth-dialog {
  width: min(calc(100% - 36px), 420px);
  border: 0;
  border-radius: 24px;
  background: var(--surface-solid);
  padding: 0;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.2);
}

.auth-dialog::backdrop {
  background: rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(4px);
}

.auth-dialog form {
  position: relative;
  display: grid;
  gap: 16px;
  padding: 28px;
}

.auth-dialog h2 {
  margin: 0;
  padding-right: 26px;
  font-size: 25px;
  letter-spacing: -0.02em;
}

.auth-dialog p {
  margin: -6px 0 4px;
  color: var(--secondary);
  font-size: 14px;
  line-height: 1.55;
}

.dialog-close {
  position: absolute;
  top: 16px;
  right: 16px;
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-muted);
  color: var(--secondary);
  font-size: 23px;
  line-height: 1;
}

.auth-email-field {
  display: grid;
  gap: 8px;
  color: var(--secondary);
  font-size: 13px;
  font-weight: 650;
}

.auth-email-field input {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--separator);
  border-radius: 13px;
  background: var(--surface-muted);
  padding: 0 14px;
  color: var(--text);
}

.auth-sign-out {
  margin-top: -6px;
}

@media (max-width: 760px) {
  :root {
    --radius-large: 20px;
    --radius-medium: 15px;
  }

  .sidebar {
    display: none;
  }

  .main-content {
    margin-left: 0;
  }

  .mobile-header {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    min-height: calc(58px + env(safe-area-inset-top));
    align-items: flex-end;
    gap: 10px;
    border-bottom: 1px solid var(--separator);
    background: rgba(248, 248, 250, 0.84);
    padding: env(safe-area-inset-top) 18px 10px;
    backdrop-filter: saturate(180%) blur(24px);
    -webkit-backdrop-filter: saturate(180%) blur(24px);
  }

  .mobile-brand-mark {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    font-size: 17px;
  }

  .mobile-title {
    align-self: center;
    font-size: 16px;
    font-weight: 680;
  }

  .mobile-account-button {
    align-self: center;
  }

  .header-spacer {
    flex: 1;
  }

  .view {
    min-height: calc(100vh - 124px);
    padding: 30px 18px calc(100px + env(safe-area-inset-bottom));
  }

  .start-state {
    min-height: calc(100vh - 210px);
    align-content: center;
    gap: 24px;
  }

  h1 {
    font-size: 36px;
  }

  .start-copy p,
  .page-heading p {
    font-size: 15px;
  }

  .start-preview,
  .task-card,
  .editor-section,
  .feedback-section {
    padding: 20px;
  }

  .exercise-toolbar,
  .page-heading {
    align-items: flex-start;
  }

  .exercise-toolbar h1,
  .page-heading h1 {
    font-size: 34px;
  }

  .timer-card {
    min-width: 98px;
    padding: 12px 14px;
  }

  .timer-card.is-floating {
    top: calc(68px + env(safe-area-inset-top));
    right: 18px;
    z-index: 35;
  }

  .definition {
    font-size: 18px;
  }

  .task-prompt {
    padding: 16px;
  }

  .rating-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .star-rating {
    width: 100%;
  }

  .star-button {
    flex: 1;
    min-width: 0;
  }

  .page-heading {
    flex-direction: column;
    margin-bottom: 24px;
  }

  .search-field {
    width: 100%;
  }

  .history-heading {
    display: grid;
    grid-template-columns: 1fr auto;
  }

  .history-heading p {
    grid-column: 1 / -1;
  }

  .history-stat {
    min-width: 78px;
  }

  .bottom-nav {
    position: fixed;
    inset: auto 0 0;
    z-index: 40;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    min-height: calc(64px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--separator);
    background: rgba(249, 249, 251, 0.88);
    padding: 6px 8px env(safe-area-inset-bottom);
    backdrop-filter: saturate(180%) blur(24px);
    -webkit-backdrop-filter: saturate(180%) blur(24px);
  }

  .bottom-nav-item {
    min-width: 0;
    min-height: 48px;
    border-radius: 11px;
    background: transparent;
    color: var(--tertiary);
    font-size: 12px;
    font-weight: 570;
  }

  .bottom-nav-item.active {
    color: var(--accent);
    font-weight: 680;
  }

  .toast {
    bottom: calc(82px + env(safe-area-inset-bottom));
  }
}

@media (max-width: 430px) {
  .exercise-toolbar {
    align-items: flex-start;
  }

  .exercise-toolbar h1 {
    font-size: 31px;
  }

  .task-card-heading {
    align-items: flex-start;
  }

  .timer-actions {
    grid-template-columns: 1fr;
  }

  .history-card-top {
    display: grid;
    grid-template-columns: 1fr auto;
  }

  .history-rating {
    grid-column: 1 / -1;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
