/* Year in Pixels — global styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body,
#root {
  height: 100%;
}

body {
  background: #ece9e4;
  color: #1b1a18;
  font-family: 'Archivo', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

input,
textarea,
button {
  font-family: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

::selection {
  background: #e9cf3c;
}

/* ── App shell ─────────────────────────────────────────────── */

.app-shell {
  position: relative;
  width: 100%;
  max-width: 560px;
  min-height: 100dvh;
  margin: 0 auto;
  background: #f7f5f1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

@media (min-width: 640px) {
  .app-shell {
    min-height: calc(100dvh - 48px);
    margin: 24px auto;
    border-radius: 28px;
    box-shadow: 0 1px 0 rgba(27, 26, 24, 0.06), 0 24px 60px rgba(27, 26, 24, 0.18);
  }
}

.app-scroll {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}

.app-scroll::-webkit-scrollbar {
  width: 0;
}

.pad {
  padding: calc(env(safe-area-inset-top, 0px) + 14px) 16px 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ── Type ─────────────────────────────────────────────────── */

.stencil {
  font-family: 'Stardos Stencil', serif;
  font-weight: 700;
}

.eyebrow {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: #6f6a63;
  text-transform: uppercase;
}

.muted {
  color: #6f6a63;
}

/* ── Buttons ──────────────────────────────────────────────── */

.btn {
  border: none;
  cursor: pointer;
  font-weight: 600;
  transition: transform 0.08s ease, filter 0.12s ease, opacity 0.12s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.btn-primary {
  height: 52px;
  border-radius: 14px;
  background: #1b1a18;
  color: #fff;
  font-size: 16px;
}

.btn-outline {
  height: 44px;
  border-radius: 12px;
  border: 1.5px solid #1b1a18;
  background: transparent;
  color: #1b1a18;
  font-size: 14px;
}

.btn-filled-toggle {
  height: 44px;
  border-radius: 12px;
  background: #1b1a18;
  color: #fff;
  font-size: 14px;
}

.btn-ghost {
  height: 44px;
  padding: 0;
  border: none;
  background: none;
  font-size: 15px;
  cursor: pointer;
}

.btn-danger-text {
  color: #b0493f;
  font-size: 14px;
  cursor: pointer;
  border: none;
  background: none;
  padding: 0;
  height: 44px;
}

.btn-dashed {
  height: 44px;
  border: 1.5px dashed #b9b2a8;
  border-radius: 10px;
  background: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  color: #1b1a18;
}

/* ── Cards ────────────────────────────────────────────────── */

.card {
  background: #fff;
  border: 1px solid #e6e2dc;
  border-radius: 16px;
  padding: 16px;
}

.stat-card {
  background: #fff;
  border: 1px solid #e6e2dc;
  border-radius: 14px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-card .stat-label {
  font-size: 12px;
  color: #6f6a63;
}

.stat-card .stat-value {
  font-size: 22px;
  font-weight: 700;
}

.stat-card .stat-sub {
  font-size: 12px;
  color: #6f6a63;
}

.progress-track {
  height: 12px;
  border-radius: 6px;
  background: #eeeae4;
  overflow: hidden;
}

.progress-track.slim {
  height: 8px;
  border-radius: 4px;
}

.progress-fill {
  height: 100%;
  border-radius: 6px;
  transition: width 0.3s ease;
}

/* ── Inputs ───────────────────────────────────────────────── */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: #6f6a63;
}

.input {
  height: 48px;
  border: 1px solid #e6e2dc;
  border-radius: 12px;
  padding: 0 14px;
  font-size: 16px;
  background: #fff;
  color: #1b1a18;
  width: 100%;
  outline: none;
}

.input:focus {
  border-color: #9b86c4;
}

.input.small {
  height: 44px;
  border-radius: 10px;
  padding: 0 12px;
}

.textarea {
  min-height: 190px;
  border: 1px solid #e6e2dc;
  border-radius: 14px;
  padding: 14px;
  font-size: 16px;
  line-height: 1.45;
  background: #fff;
  color: #1b1a18;
  resize: none;
  width: 100%;
  outline: none;
}

.textarea:focus {
  border-color: #9b86c4;
}

input[type='number']::-webkit-outer-spin-button,
input[type='number']::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type='number'] {
  -moz-appearance: textfield;
  appearance: textfield;
}

/* ── Year grid ────────────────────────────────────────────── */

.year-grid {
  display: grid;
  gap: 2px;
}

.day-cell {
  aspect-ratio: 1;
  border-radius: 2px;
  border: none;
  padding: 0;
  position: relative;
}

.day-cell.logged {
  cursor: pointer;
}

.day-cell.unlogged {
  background: #e3dfd8;
  cursor: pointer;
}

.day-cell.future {
  background: #e3dfd8;
  opacity: 0.45;
  cursor: default;
}

.day-cell.today {
  box-shadow: inset 0 0 0 2px #1b1a18;
}

.day-cell.selected {
  box-shadow: inset 0 0 0 2.5px #1b1a18;
  z-index: 2;
}

.day-cell:hover {
  filter: brightness(0.96);
}

.legend {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  font-size: 12px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex: none;
}

/* ── Distribution bar ─────────────────────────────────────── */

.dist-bar {
  display: flex;
  height: 14px;
  border-radius: 7px;
  overflow: hidden;
  background: #eeeae4;
}

.dist-seg {
  height: 100%;
  transition: width 0.3s ease;
}

/* ── Tab bar ──────────────────────────────────────────────── */

.tabbar {
  flex: none;
  height: calc(82px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid #e6e2dc;
  background: #fff;
  display: flex;
  padding-bottom: calc(22px + env(safe-area-inset-bottom, 0px));
}

.tab {
  flex: 1;
  border: none;
  background: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 0;
  cursor: pointer;
}

.tab-bar {
  width: 28px;
  height: 3px;
  border-radius: 2px;
  background: transparent;
}

.tab.active .tab-bar {
  background: #1b1a18;
}

.tab-label {
  font-size: 14px;
  color: #6f6a63;
  font-weight: 400;
}

.tab.active .tab-label {
  color: #1b1a18;
  font-weight: 700;
}

/* ── Overlays / sheets ────────────────────────────────────── */

.overlay {
  position: absolute;
  inset: 0;
  background: rgba(27, 26, 24, 0.38);
  z-index: 20;
}

.sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  top: 12%;
  border-radius: 22px 22px 0 0;
  background: #f7f5f1;
  z-index: 21;
  display: flex;
  flex-direction: column;
  padding: 18px 16px calc(24px + env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
  animation: sheetUp 0.22s cubic-bezier(0.2, 0.8, 0.3, 1);
}

.sheet-handle {
  width: 40px;
  height: 5px;
  border-radius: 3px;
  background: #cfc9c0;
  align-self: center;
  margin-bottom: 6px;
  flex: none;
}

.fullsheet {
  position: absolute;
  inset: 0;
  background: #f7f5f1;
  z-index: 30;
  display: flex;
  flex-direction: column;
  padding: calc(env(safe-area-inset-top, 0px) + 14px) 16px 28px;
  overflow-y: auto;
  gap: 18px;
  animation: fadeIn 0.18s ease;
}

@media (min-width: 640px) {
  .sheet {
    top: 50%;
    bottom: auto;
    left: 50%;
    right: auto;
    width: 480px;
    max-height: 86%;
    transform: translate(-50%, -50%);
    border-radius: 24px;
    padding: 22px 24px 28px;
    animation: modalIn 0.2s cubic-bezier(0.2, 0.8, 0.3, 1);
  }

  .fullsheet {
    inset: 32px;
    border-radius: 24px;
    box-shadow: 0 24px 60px rgba(27, 26, 24, 0.25);
  }
}

.sheet-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 48px;
  flex: none;
}

@keyframes sheetUp {
  from {
    transform: translateY(40px);
    opacity: 0.4;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes modalIn {
  from {
    transform: translate(-50%, -46%);
    opacity: 0.3;
  }
  to {
    transform: translate(-50%, -50%);
    opacity: 1;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0.35;
  }
  to {
    opacity: 1;
  }
}

/* ── Rating picker ────────────────────────────────────────── */

.rate-row {
  display: flex;
  justify-content: space-between;
  gap: 4px;
}

.rate-btn {
  border: none;
  background: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  width: 62px;
}

.rate-swatch {
  width: 48px;
  height: 48px;
  border-radius: 10px;
}

.rate-swatch.selected {
  box-shadow: inset 0 0 0 3px #1b1a18;
}

.rate-label {
  font-size: 12px;
  color: #1b1a18;
  font-weight: 400;
}

.rate-btn.selected .rate-label {
  font-weight: 700;
}

/* ── Journal ──────────────────────────────────────────────── */

.journal-list {
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid #e6e2dc;
  border-radius: 16px;
  overflow: hidden;
}

.journal-item {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid #eeeae4;
  cursor: pointer;
  align-items: flex-start;
  text-align: left;
  width: 100%;
  border-left: none;
  border-right: none;
  border-top: none;
  background: none;
}

.journal-item:last-child {
  border-bottom: none;
}

.journal-item:active {
  background: #f7f5f1;
}

.journal-square {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  flex: none;
}

/* ── Goals ────────────────────────────────────────────────── */

.goal-card {
  background: #fff;
  border: 1px solid #e6e2dc;
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.segmented {
  display: flex;
  background: #ebe7e1;
  border-radius: 12px;
  padding: 4px;
  gap: 4px;
}

.segment {
  flex: 1;
  height: 40px;
  border: none;
  border-radius: 9px;
  background: transparent;
  font-size: 14px;
  font-weight: 600;
  color: #1b1a18;
  cursor: pointer;
}

.segment.active {
  background: #fff;
  box-shadow: 0 1px 3px rgba(27, 26, 24, 0.14);
}

/* ── Reading test ─────────────────────────────────────────── */

.test-passage {
  font-size: 17px;
  line-height: 1.65;
  color: #1b1a18;
  background: #fff;
  border: 1px solid #e6e2dc;
  border-radius: 14px;
  padding: 18px;
}

.test-timer {
  font-variant-numeric: tabular-nums;
  font-size: 28px;
  font-weight: 700;
  text-align: center;
}

/* ── Empty states ─────────────────────────────────────────── */

.empty {
  text-align: center;
  color: #6f6a63;
  font-size: 14px;
  line-height: 1.5;
  padding: 40px 24px;
  border: 1px dashed #d8d2c9;
  border-radius: 16px;
}

.empty-title {
  font-size: 15px;
  font-weight: 700;
  color: #1b1a18;
  margin-bottom: 4px;
}

/* ── Misc ─────────────────────────────────────────────────── */

.divider-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.row-label {
  font-size: 13px;
  font-weight: 600;
  color: #6f6a63;
}

.forecast-card {
  background: #1b1a18;
  color: #fff;
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.forecast-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.forecast-value {
  font-size: 20px;
  font-weight: 700;
}

.forecast-cap {
  font-size: 12px;
  color: #cfc9c0;
}

.forecast-status {
  font-size: 13px;
  color: #ef8fae;
}

.forecast-status.ok {
  color: #7cc26b;
}

/* ── Lock screen / PIN pad ─────────────────────────────────── */

.pin-dots {
  display: flex;
  gap: 14px;
}

.pin-dot {
  width: 14px;
  height: 14px;
  border-radius: 7px;
  background: #e3dfd8;
  transition: background 0.12s ease, transform 0.12s ease;
}

.pin-dot.filled {
  background: #1b1a18;
  transform: scale(1.05);
}

.pin-dot.err {
  background: #b0493f;
}

.pin-error {
  min-height: 18px;
  font-size: 13px;
  color: #b0493f;
  text-align: center;
  transition: opacity 0.15s ease;
}

.pin-pad {
  display: grid;
  grid-template-columns: repeat(3, 72px);
  gap: 12px;
  justify-content: center;
}

.pin-key {
  height: 60px;
  border: none;
  background: #fff;
  border: 1px solid #e6e2dc;
  border-radius: 16px;
  font-size: 24px;
  font-weight: 600;
  color: #1b1a18;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.12s ease;
}

.pin-key:active {
  transform: scale(0.95);
  background: #eeeae4;
}

/* ── Status chips ──────────────────────────────────────────── */

.status-chip {
  font-size: 12px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 10px;
  background: #eeeae4;
  color: #6f6a63;
  white-space: nowrap;
  flex: none;
}

.status-chip.ok {
  background: #e5f2df;
  color: #4c7a3d;
}

.status-chip.mid {
  background: #eef0f4;
  color: #3d5a80;
}

.status-chip.bad {
  background: #f7e4e1;
  color: #b0493f;
}

/* ── Reading test meta ─────────────────────────────────────── */

.passage-meta {
  font-size: 12px;
  color: #6f6a63;
  text-align: center;
  line-height: 1.4;
}
