:root {
  --app-ink: #0c2a3a;
  --app-sea: #1a5c6e;
  --app-sea-hover: #154a59;
  --app-mist: #d8ece8;
  --app-accent: #e8a54b;
  --app-surface: rgba(255, 252, 247, 0.92);
  --app-bg: #faf9f6;
  --app-border: #b7c9ce;
  --app-border-light: rgba(26, 92, 110, 0.1);
  --app-focus: rgba(26, 92, 110, 0.35);
  --app-danger: #ef4444;
  --app-danger-hover: #b91c1c;
  --font-sans: Manrope, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-serif: Fraunces, Georgia, serif;
}


* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--app-ink);
  background: var(--app-bg);
}

h1,
h2,
h3 {
  font-family: var(--font-serif);
  color: var(--app-ink);
}


.modal-message--danger {
  color: var(--app-danger);
  font-style: italic;
}

.home-hsk-info-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 1.5rem;
  height: 1.5rem;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  background-color: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  box-shadow: none;
  color: #b45309;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}

.home-hsk-info-button:hover, .home-hsk-info-button:focus-visible {
  background: transparent;
  background-color: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  color: #92400e;
  outline: none;
}

.home-hsk-info-icon {
  width: 1.35rem;
  height: 1.35rem;
}

.home-hsk-info-text {
  margin: 0;
  font-size: 0.95rem;
  color: #374151;
  line-height: 1.5;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(12, 42, 58, 0.55);
  backdrop-filter: blur(2px);
  z-index: 1000;
}

.modal-overlay.modal-overlay--stacked {
  z-index: 1100;
}

.modal-dialog {
  width: 100%;
  max-width: 28rem;
  padding: 1.5rem;
  border-radius: 0.75rem;
  background: var(--app-surface);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 24px 48px rgba(6, 24, 36, 0.25);
}

.modal-title {
  margin: 0 0 1.25rem;
  font-size: 1.25rem;
  font-weight: 700;
  color: #111827;
}

.modal-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.modal-field {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.modal-field-checkbox, .modal-field-toggle {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.modal-field-toggle .modal-field-label {
  margin: 0;
}

.toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: relative;
  display: inline-block;
  width: 2.75rem;
  height: 1.5rem;
  border-radius: 9999px;
  background: var(--app-border);
  transition: background-color 0.2s ease;
}

.toggle-slider::before {
  content: "";
  position: absolute;
  top: 0.125rem;
  left: 0.125rem;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  background: #ffffff;
  transition: transform 0.2s ease;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.2);
}

.toggle input:checked + .toggle-slider {
  background: var(--app-sea);
}

.toggle input:checked + .toggle-slider::before {
  transform: translateX(1.25rem);
}

.toggle input:focus-visible + .toggle-slider {
  outline: 2px solid var(--app-focus);
  outline-offset: 2px;
}

.modal-field-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: #374151;
}

.modal-field input[type="text"] {
  width: 100%;
  margin-top: 0;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--app-border);
  border-radius: 0.55rem;
  background: #ffffff;
  color: var(--app-ink);
  font-size: 0.95rem;
  transition: border-color 0.15s ease, outline 0.15s ease;
}

.modal-field input[type="text"]:read-only {
  background: #f3f4f6;
  color: #6b7280;
}

.modal-field input[type="text"]:focus {
  outline: 2px solid var(--app-focus);
  border-color: var(--app-sea);
}

.modal-message {
  margin: 0 0 1.5rem;
  color: #111827;
  line-height: 1.5;
}

.modal-dialog--warning {
  border-color: #f59e0b;
  background: #fffbeb;
}

.modal-dialog--warning .modal-message {
  color: #92400e;
}

.modal-dialog--wide {
  max-width: 40rem;
  max-height: min(90vh, 48rem);
  overflow-y: auto;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* ---------------------------------------------------------------------
 * Button (see Button.tsx) — the app's only button design system.
 * kind = semantic color (cancel/confirm/danger), variant = context sizing.
 * ------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  margin-top: 0;
  border-radius: 0.5rem;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.btn svg {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
}

.btn-cancel {
  border: 1px solid var(--app-border);
  background: transparent;
  color: var(--app-ink);
}

.btn-cancel:hover:not(:disabled) {
  background-color: var(--app-border-light);
}

.btn-confirm {
  border: 1px solid var(--app-sea);
  background: transparent;
  color: var(--app-sea);
}

.btn-confirm:hover:not(:disabled) {
  background-color: var(--app-border-light);
}

.btn-danger {
  border: 1px solid var(--app-danger);
  background: transparent;
  color: var(--app-danger);
}

.btn-danger:hover:not(:disabled) {
  background-color: #fef2f2;
}

.btn-page {
  padding: 0.7rem 1rem;
  font-size: 0.95rem;
  font-weight: 600;
  backdrop-filter: blur(10px);
}

.btn-modal {
  padding: 0.625rem 1rem;
  font-size: 0.95rem;
  font-weight: 500;
}

.btn-banner {
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
}

.btn-table {
  padding: 0.375rem 0.75rem;
  border-radius: 0.375rem;
  font-size: 0.875rem;
  font-weight: 500;
}

/* Small table-row actions read better filled than outlined. */
.btn-table.btn-confirm {
  border: none;
  background-color: var(--app-sea);
  color: #ffffff;
}

.btn-table.btn-confirm:hover:not(:disabled) {
  background-color: var(--app-sea-hover);
}

.btn-table.btn-danger {
  border: none;
  background-color: #dc2626;
  color: #ffffff;
}

.btn-table.btn-danger:hover:not(:disabled) {
  background-color: #b91c1c;
}

.btn-confirmation {
  padding: 0.625rem 1rem;
  font-size: 0.95rem;
  font-weight: 500;
}

/* The one place a filled/heavy button is intentional: the actual
   validation button of a yes/no confirmation dialog (see ConfirmModal). */
.btn-confirmation.btn-confirm {
  border: none;
  background-color: var(--app-sea);
  color: #ffffff;
}

.btn-confirmation.btn-confirm:hover:not(:disabled) {
  background-color: var(--app-sea-hover);
}

.btn-confirmation.btn-danger {
  border: none;
  background-color: var(--app-danger);
  color: #ffffff;
}

.btn-confirmation.btn-danger:hover:not(:disabled) {
  background-color: var(--app-danger-hover);
}

.table-error {
  color: #b91c1c;
}


.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-main {
  flex: 1;
  padding: 1.5rem;
}


.page {
  max-width: 48rem;
  margin: 0 auto;
}

.page--full-width {
  max-width: none;
  width: 100%;
  margin: 0;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.page-header h1 {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 700;
}

.page-header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.page-content {
  color: #374151;
  line-height: 1.6;
}

@media (max-width: 640px) {
  .page-header {
    flex-wrap: wrap;
  }

  .page-header h1 {
    flex-basis: 100%;
  }

  .page-header-actions {
    flex-wrap: wrap;
  }
}


.app-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 0 0 1.25rem;
  padding: 0.55rem 1rem;
  border: 1px solid #93c5fd;
  border-radius: 0.75rem;
  background: #eff6ff;
}

.app-banner-text {
  margin: 0;
  flex: 1;
  min-width: 0;
  color: #1e40af;
  line-height: 1.45;
  font-size: 0.95rem;
}

.app-banner :global(.btn-confirm) {
  flex-shrink: 0;
  border-color: #2563eb;
  background: #ffffff;
  color: #1e40af;
}

.app-banner :global(.btn-confirm):hover:not(:disabled) {
  background: #dbeafe;
}

.app-banner--warning {
  border-color: #f59e0b;
  background: #fffbeb;
}

.app-banner--warning .app-banner-text {
  color: #92400e;
}

.app-banner--warning :global(.btn-confirm) {
  border-color: #d97706;
  color: #92400e;
}

.app-banner--warning :global(.btn-confirm):hover:not(:disabled) {
  background: #fef3c7;
}

@media (max-width: 640px) {
  .app-banner {
    flex-wrap: wrap;
  }

  .app-banner-text {
    flex-basis: 100%;
  }
}


.grammar-level-section {
  margin-bottom: 1rem;
  border: 1px solid var(--app-border-light);
  border-radius: 0.75rem;
  overflow: hidden;
}

.grammar-level-summary {
  cursor: pointer;
  padding: 0.75rem 1.25rem;
  font-weight: 650;
  color: #111827;
}

.grammar-level-section-1 { background: #eef5ff; }
.grammar-level-section-2 { background: #eefbf3; }
.grammar-level-section-3 { background: #fff8e8; }
.grammar-level-section-4 { background: #fdf0f6; }
.grammar-level-section-5 { background: #f3f0fd; }
.grammar-level-section-6 { background: #eafbfa; }

.grammar-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  background: var(--app-surface);
}

.grammar-table th, .grammar-table td {
  padding: 0.6rem 1.25rem;
  text-align: left;
  border-top: 1px solid var(--app-border-light);
}

.grammar-table th {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--app-ink);
}

.grammar-table-col-number {
  width: 2.75rem;
  white-space: nowrap;
}

/* table-layout: fixed needs every column's width pinned except the one that
   should flex; status/score get just enough room for their content (longest
   translated label) and sit on the right, lesson (no width set) takes
   whatever's left and ellipses via .grammar-row-title-text. */
.grammar-table th:nth-child(3), .grammar-table td:nth-child(3) {
  width: 9.5rem;
}

.grammar-table th:nth-child(4), .grammar-table td:nth-child(4) {
  width: 4rem;
  padding-right: calc(1.25rem + 10px);
}

.grammar-table th:nth-child(3), .grammar-table td:nth-child(3),
.grammar-table th:nth-child(4), .grammar-table td:nth-child(4) {
  text-align: right;
  white-space: nowrap;
}

.grammar-row {
  cursor: pointer;
}

.grammar-row:hover {
  background: var(--app-bg);
}

.grammar-row:focus-visible {
  outline: 2px solid var(--app-focus);
  outline-offset: -2px;
}

.grammar-row-locked {
  cursor: not-allowed;
  opacity: 0.6;
}

.grammar-row-locked:hover {
  background: none;
}

.grammar-row-writing {
  cursor: pointer;
  color: var(--app-ink);
}

.grammar-row-writing:hover {
  background: var(--app-bg);
}

.grammar-row-writing:focus-visible {
  outline: 2px solid var(--app-focus);
  outline-offset: -2px;
}

/* Lighter tints of the section palette in grammar-level-section-N above. */
.grammar-row-writing-1 { background: #f6faff; }
.grammar-row-writing-2 { background: #f6fdf9; }
.grammar-row-writing-3 { background: #fffbf3; }
.grammar-row-writing-4 { background: #fef7fa; }
.grammar-row-writing-5 { background: #f9f7fe; }
.grammar-row-writing-6 { background: #f4fdfc; }

.grammar-row-writing-icon {
  width: 0.9rem;
  height: 0.9rem;
  color: var(--app-ink);
}

.grammar-row-title {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
  font-weight: 600;
  color: #111827;
}

.grammar-row-title-text {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  min-width: 0;
}

.grammar-row-lock-icon {
  width: 1rem;
  height: 1rem;
  color: #6b7280;
  flex-shrink: 0;
}

.grammar-status {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.15rem 0.55rem;
  border-radius: 9999px;
  font-size: 0.78rem;
  font-weight: 650;
  letter-spacing: 0.01em;
}

.grammar-status-icon {
  width: 0.9rem;
  height: 0.9rem;
  flex-shrink: 0;
}

.grammar-status-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 9999px;
  background: currentColor;
  flex-shrink: 0;
}

.grammar-status-todo {
  background: #f3f4f6;
  color: #6b7280;
}

.grammar-status-wip {
  background: #fef3c7;
  color: #92400e;
}

.grammar-status-done {
  background: #dcfce7;
  color: #166534;
}

.grammar-status-skip {
  background: #e5e7eb;
  color: #374151;
}

.grammar-status-mastered {
  background: #dbeafe;
  color: #1d4ed8;
}

.grammar-score {
  font-weight: 700;
}

.grammar-score-good {
  color: #16a34a;
}

.grammar-score-medium {
  color: #b45309;
}

.grammar-score-low {
  color: var(--app-danger);
}

.grammar-score-mastered {
  color: #1d4ed8;
}

.grammar-level-gauges {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.grammar-level-gauge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
}

.grammar-level-gauge-ring {
  width: 2.75rem;
  height: 2.75rem;
  transform: rotate(-90deg);
}

.grammar-level-gauge-track {
  fill: none;
  stroke: var(--app-border-light);
  stroke-width: 4;
}

.grammar-level-gauge-progress {
  fill: none;
  stroke: var(--app-sea);
  stroke-width: 4;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.6s ease-out;
}

.grammar-level-gauge-text {
  transform: rotate(90deg);
  transform-box: fill-box;
  transform-origin: center;
  font-size: 0.55rem;
  font-weight: 700;
  fill: var(--app-ink);
  text-anchor: middle;
}

.grammar-level-gauge-label {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--app-ink);
}

@media (max-width: 640px) {
  .grammar-level-gauges {
    flex-wrap: wrap;
  }

  /* One column, two lines per lesson: title on top, status + score below.
     The "#" column is dropped entirely on this narrow a screen. */
  .grammar-table thead {
    display: none;
  }

  .grammar-table, .grammar-table tbody {
    display: block;
    width: 100%;
  }

  .grammar-row, .grammar-row-writing {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "title title"
      "status score";
    gap: 0.2rem 0.5rem;
    padding: 0.65rem 1rem;
    border-top: 1px solid var(--app-border-light);
  }

  .grammar-table td {
    padding: 0;
    border-top: none;
  }

  .grammar-table td:nth-child(1) {
    display: none;
  }

  .grammar-row-title {
    grid-area: title;
  }

  .grammar-table td:nth-child(3) {
    grid-area: status;
    text-align: left;
  }

  .grammar-table td:nth-child(4) {
    grid-area: score;
    text-align: right;
  }
}



.grammar-row-writing { cursor: default; }
.grammar-row-writing:hover { background: none; }
