/* ──────────────────────────────────────────────────────────────────
 * InkWell · design tokens + base styles
 * Stationery aesthetic: warm cream paper, vermillion ink, soft shadows
 * ────────────────────────────────────────────────────────────────── */

:root {
  /* ── Paper / ink palette ── */
  --paper:        #faf6ec;
  --paper-shade: #f4ecd8;
  --paper-deep:  #ece1c4;
  --ink:         #1b1815;
  --ink-2:       #3d352a;
  --pencil:      #7a6f5e;
  --faint:       #c4b89f;
  --hairline:    rgba(27, 24, 21, 0.10);
  --hairline-2:  rgba(27, 24, 21, 0.06);

  /* ── Accent (warm vermillion — the "ink" in InkWell) ── */
  --accent:       #b8553a;
  --accent-soft:  #f1d3bd;
  --accent-deep:  #8c3e29;

  /* ── Group / paper-bg seasonals ── */
  --highlight: #f6dd9a;
  --sage:      #c0d6b1;
  --sage-bg:   #eef3e4;
  --sky:       #aac6d6;
  --sky-bg:    #e5eff5;
  --rose:      #e5acac;
  --rose-bg:   #f6e0e0;
  --lilac:     #c7b6d9;

  /* ── Shadows ── */
  --shadow-soft:   0 1px 2px rgba(27,24,21,0.05), 0 2px 12px rgba(27,24,21,0.05);
  --shadow-card:   0 1px 2px rgba(27,24,21,0.05), 0 6px 18px rgba(27,24,21,0.06);
  --shadow-raised: 0 4px 16px rgba(27,24,21,0.10), 0 12px 32px rgba(27,24,21,0.08);
  --shadow-press:  0 0 0 1px rgba(27,24,21,0.04), 0 1px 2px rgba(27,24,21,0.04);

  /* ── Radii ── */
  --r-xs: 6px;
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 28px;

  /* ── Spacing ── */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-7: 32px;

  /* ── Type ── */
  --font-serif: 'Lora', 'Iowan Old Style', Georgia, serif;
  --font-ui:    'DM Sans', system-ui, sans-serif;
  --font-mono:  'JetBrains Mono', ui-monospace, monospace;
  --font-hand:  'Caveat', cursive;

  /* ── Easings ── */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

  /* ── App chrome ── */
  --tab-h: 64px;
  --top-h: 56px;
}

/* ── Theme: cute (rosy / peach) ── */
[data-tone="cute"] {
  --paper:       #fff8f6;
  --paper-shade: #ffe7df;
  --paper-deep:  #fcd2c4;
  --ink:         #4a2a23;
  --ink-2:       #6b3d33;
  --pencil:      #9b6e63;
  --faint:       #e0bdb1;
  --accent:      #d96e6e;
  --accent-soft: #f6c8c8;
  --accent-deep: #a4413f;
  --hairline:    rgba(74,42,35,0.10);
  --hairline-2:  rgba(74,42,35,0.06);
}

/* ── Theme: mono ── */
[data-tone="mono"] {
  --paper:       #f7f6f3;
  --paper-shade: #ecebe7;
  --paper-deep:  #d9d8d2;
  --ink:         #111111;
  --ink-2:       #2b2b2b;
  --pencil:      #6a6a6a;
  --faint:       #b8b8b8;
  --accent:      #111111;
  --accent-soft: #d9d8d2;
  --accent-deep: #000000;
  --hairline:    rgba(0,0,0,0.10);
  --hairline-2:  rgba(0,0,0,0.05);
}

/* ─── Base reset / page chrome ─────────────────────────────────── */
* { box-sizing: border-box; }
html, body, #root { height: 100%; margin: 0; padding: 0; }

html, body {
  /* prevent rubber-band / drag-to-refresh */
  overscroll-behavior: none;
  -webkit-overflow-scrolling: touch;
}

body {
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* Subtle paper grain */
  background-image:
    radial-gradient(circle at 1px 1px, rgba(124,109,84,0.10) 0.5px, transparent 1px),
    radial-gradient(circle at 50% 30%, rgba(184,85,58,0.04), transparent 60%);
  background-size: 28px 28px, auto;
  overflow: hidden;
}

button, input, textarea {
  font: inherit;
  color: inherit;
  background: transparent;
  border: none;
  outline: none;
}

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

/* ─── App phone-frame for desktop ──────────────────────────────── */
/* On desktop, render the app inside a phone-sized container so the
 * design reads at the intended scale; on mobile, fill the viewport. */
.app-root {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.app-frame {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  background: var(--paper);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

@media (min-width: 540px) {
  body { background: #ebe2cf;
    background-image:
      radial-gradient(circle at 1px 1px, rgba(124,109,84,0.18) 0.5px, transparent 1px); }
  .app-frame {
    width: 412px; height: 880px; max-height: 92vh;
    border-radius: 44px;
    border: 1px solid rgba(27,24,21,0.10);
    box-shadow: var(--shadow-raised), 0 0 0 10px #2a241c, 0 0 0 11px rgba(0,0,0,0.18);
  }
}

/* ─── Scroll surfaces ──────────────────────────────────────────── */
.scroll {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
}
.scroll::-webkit-scrollbar { width: 0; height: 0; }

/* ─── Typography helpers ───────────────────────────────────────── */
.t-display { font-family: var(--font-serif); font-weight: 500; letter-spacing: -0.01em; }
.t-hand    { font-family: var(--font-hand); font-weight: 500; }
.t-mono    { font-family: var(--font-mono); }
.t-meta    { font-family: var(--font-mono); font-size: 11px; color: var(--pencil); letter-spacing: 0.04em; text-transform: uppercase; }

/* ─── Status bar (faux) — HIDDEN ──────────────────────────────── */
/* Removed: PWA standalone mode shows the real device status bar.
   Keeping CSS rule as display:none in case component still renders. */
.statusbar {
  display: none;
}

/* ─── Top bar ──────────────────────────────────────────────────── */
.topbar {
  height: var(--top-h); padding: 0 16px;
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
  position: relative;
}
.topbar .title { font-family: var(--font-serif); font-size: 18px; font-weight: 500; }
.topbar .icon-btn {
  width: 40px; height: 40px; display: flex; align-items: center; justify-content: center;
  border-radius: 999px; transition: background 0.15s;
}
.topbar .icon-btn:active { background: var(--paper-shade); }

/* ─── Bottom tab bar ───────────────────────────────────────────── */
.tabbar {
  height: var(--tab-h);
  padding: 4px 8px calc(env(safe-area-inset-bottom, 0px) + 4px);
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(250, 246, 236, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--hairline);
  flex-shrink: 0;
  position: relative;
  z-index: 10;
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 0; color: var(--pencil);
  transition: color 0.18s, transform 0.18s;
}
.tab.active { color: var(--accent); }
.tab .label { font-size: 10px; font-weight: 500; letter-spacing: 0.01em; }
.tab:active { transform: scale(0.94); }

.fab {
  width: 56px; height: 56px; border-radius: 28px;
  background: var(--ink); color: var(--paper);
  display: flex; align-items: center; justify-content: center;
  margin-top: -22px;
  box-shadow: 0 6px 16px rgba(27,24,21,0.30), 0 2px 6px rgba(27,24,21,0.20);
  transition: transform 0.15s var(--ease-spring);
  flex-shrink: 0;
}
.fab:active { transform: scale(0.92); }

/* ─── Card ─────────────────────────────────────────────────────── */
.card {
  background: #fff;
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  padding: 14px;
  box-shadow: var(--shadow-card);
  transition: transform 0.18s var(--ease-out), box-shadow 0.18s;
}
.card:active { transform: scale(0.985); }

/* ─── Chip ─────────────────────────────────────────────────────── */
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 6px 12px;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  background: #fff;
  font-size: 13px; font-weight: 500;
  color: var(--ink-2);
  transition: all 0.15s;
  white-space: nowrap;
}
.chip:active { transform: scale(0.94); }
.chip.active { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.chip.accent { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ─── Button ───────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px;
  border-radius: 999px;
  font-weight: 600; font-size: 14px;
  background: #fff;
  border: 1px solid var(--hairline);
  color: var(--ink);
  transition: transform 0.15s, background 0.15s;
}
.btn.primary { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.btn.accent  { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.ghost   { background: transparent; border-color: transparent; }
.btn:active  { transform: scale(0.96); }
.btn.sm      { padding: 6px 12px; font-size: 12px; }

/* ─── Inputs ───────────────────────────────────────────────────── */
.field-title {
  font-family: var(--font-serif);
  font-size: 28px; font-weight: 500;
  background: transparent; border: none; outline: none; padding: 0;
  width: 100%; color: var(--ink); letter-spacing: -0.015em;
}
.field-title::placeholder { color: var(--faint); font-style: italic; }
.field-body {
  font-family: var(--font-ui); font-size: 15px; line-height: 26px;
  background: transparent; border: none; outline: none; resize: none; padding: 0;
  width: 100%; color: var(--ink-2);
}
.field-body::placeholder { color: var(--faint); font-style: italic; }

.input {
  width: 100%; padding: 10px 14px;
  background: #fff;
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  font-size: 14px;
}

/* ─── Search field ─────────────────────────────────────────────── */
.search {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 14px;
  background: var(--paper-shade);
  border-radius: 999px;
  color: var(--pencil);
}
.search input { width: 100%; font-size: 14px; }

/* ─── Drawer ───────────────────────────────────────────────────── */
.drawer-backdrop {
  position: absolute; inset: 0; z-index: 50;
  background: rgba(27, 24, 21, 0.35);
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s var(--ease-out);
}
.drawer-backdrop.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: absolute; top: 0; bottom: 0; left: 0;
  width: 84%; max-width: 340px; z-index: 51;
  background: var(--paper);
  border-right: 1px solid var(--hairline);
  transform: translateX(-100%);
  transition: transform 0.28s var(--ease-out);
  display: flex; flex-direction: column;
  box-shadow: 8px 0 32px rgba(27,24,21,0.18);
}
.drawer.open { transform: translateX(0); }

/* ─── Editor (full-screen overlay) ─────────────────────────────── */
.editor {
  position: absolute; inset: 0; z-index: 40;
  display: flex; flex-direction: column;
  background: var(--paper);
  transform: translateY(100%);
  transition: transform 0.30s var(--ease-out);
}
.editor.open { transform: translateY(0); }

/* ─── Note paper variants ──────────────────────────────────────── */
.paper-cream { background: #fdf9ed; }
.paper-sage  { background: var(--sage-bg); }
.paper-sky   { background: var(--sky-bg); }
.paper-sepia { background: #f6ecd0; }

.tex-ruled  { background-image: repeating-linear-gradient(transparent 0 25px, rgba(0,0,0,0.06) 25px 26px); }
.tex-dotted { background-image: radial-gradient(circle, rgba(0,0,0,0.13) 0.8px, transparent 1.5px); background-size: 18px 18px; }
.tex-grid   { background-image: linear-gradient(rgba(0,0,0,0.05) 1px, transparent 1px), linear-gradient(90deg, rgba(0,0,0,0.05) 1px, transparent 1px); background-size: 22px 22px; }
.tex-plain  { background-image: none; }

/* ─── Calendar grid ────────────────────────────────────────────── */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-day {
  aspect-ratio: 1; position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border-radius: 10px; font-size: 14px; font-weight: 500;
  transition: background 0.15s;
}
.cal-day.outside { color: var(--faint); }
.cal-day.today {
  background: var(--ink); color: var(--paper);
}
.cal-day.has {
  background: var(--accent-soft);
}
.cal-day.today.has { background: var(--ink); }
.cal-day .dot {
  width: 4px; height: 4px; border-radius: 50%; margin-top: 2px;
  background: var(--accent);
}
.cal-day.today .dot { background: var(--paper); }

/* ─── Animations ───────────────────────────────────────────────── */
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px);} to { opacity: 1; transform: translateY(0);} }
.fade-in { animation: fadeIn 0.25s var(--ease-out) both; }

@keyframes pop { 0%{transform:scale(.86); opacity:0} 100%{transform:scale(1); opacity:1} }
.pop { animation: pop 0.22s var(--ease-spring) both; }

/* ─── Misc ─────────────────────────────────────────────────────── */
.hr { height: 1px; background: var(--hairline); border: 0; margin: 8px 0; }
.hr-dashed { height: 0; border-top: 1px dashed var(--hairline); margin: 8px 0; }

/* prevent text selection on chrome elements */
.tabbar, .topbar, .statusbar { user-select: none; -webkit-user-select: none; }

/* checkbox */
.checkbox {
  width: 22px; height: 22px; border-radius: 6px;
  border: 1.5px solid var(--ink-2);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  background: #fff;
  transition: background 0.15s;
}
.checkbox.checked {
  background: var(--accent); border-color: var(--accent);
  color: #fff;
}

/* ─── Group dot ────────────────────────────────────────────────── */
.group-dot {
  width: 10px; height: 10px; border-radius: 50%;
  display: inline-block; flex-shrink: 0;
}

/* ─── Empty state ──────────────────────────────────────────────── */
.empty {
  padding: 40px 24px; text-align: center; color: var(--pencil);
}
.empty .e-emoji { font-size: 48px; margin-bottom: 8px; }
.empty .e-title { font-family: var(--font-serif); font-size: 20px; margin-bottom: 4px; color: var(--ink); }
.empty .e-sub { font-size: 13px; }

/* ─── Toast ────────────────────────────────────────────────────── */
.toast-wrap {
  position: absolute; left: 0; right: 0; top: 60px;
  z-index: 100; display: flex; justify-content: center;
  pointer-events: none;
}
.toast {
  background: var(--ink); color: var(--paper);
  padding: 10px 18px; border-radius: 999px; font-size: 13px;
  box-shadow: var(--shadow-raised);
  animation: fadeIn 0.22s var(--ease-out);
}
