/* Night & teal. Dark at night, light in the daytime: follows the phone. */
:root {
  --bg: #F5F7F4;
  --card: #FFFFFF;
  --card-2: #EAF0EC;
  --line: #DCE5E0;
  --ink: #1A2626;
  --ink-2: #344241;
  --muted: #5B6B69;
  --teal: #2D8379;        /* lines, pills, borders */
  --teal-text: #22675F;   /* teal used as text: darker so it reads on the light background */
  --teal-soft: #BFDAD4;
  --teal-wash: rgba(45, 131, 121, 0.10);
  --btn: #22675F;         /* teal button: dark enough for white text */
  --on-teal: #FFFFFF;
  --danger: #A33A2C;
  --toast-bg: #1A2626;
  --toast-ink: #F5F7F4;
  --toast-act: #7FD3C8;
  --shadow: 0 1px 2px rgba(26, 38, 38, 0.05), 0 6px 18px rgba(26, 38, 38, 0.05);
  --row-line: rgba(45, 131, 121, 0.14);
  --serif: 'Literata', Georgia, serif;
  --sans: 'Inter', system-ui, -apple-system, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0F1A1C;
    --card: #172628;
    --card-2: #132123;
    --line: #253638;
    --ink: #E8F0EE;
    --ink-2: #CBD8D5;
    --muted: #9AAEAB;
    --teal: #4FB3A9;
    --teal-text: #6CC5BB;
    --teal-soft: #2B4E4B;
    --teal-wash: rgba(79, 179, 169, 0.14);
    --btn: #4FB3A9;
    --on-teal: #0F1A1C;
    --danger: #E07A6A;
    --toast-bg: #E8F0EE;
    --toast-ink: #0F1A1C;
    --toast-act: #22675F;
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
    --row-line: rgba(79, 179, 169, 0.10);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--sans); -webkit-text-size-adjust: 100%; }
body { min-height: 100dvh; -webkit-tap-highlight-color: transparent; overscroll-behavior-y: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
button:focus-visible, textarea:focus-visible, input:focus-visible, a:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
[hidden] { display: none !important; }

.screen { position: relative; min-height: 100dvh; display: flex; flex-direction: column; max-width: 560px; margin: 0 auto; }

/* A faint ring of dots in the corner */
.screen::before {
  content: ''; position: fixed; top: -120px; right: -120px; width: 330px; height: 330px; pointer-events: none; opacity: 0.12; z-index: 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cg fill='none' stroke='%234FB3A9' stroke-width='0.8'%3E%3Ccircle cx='50' cy='50' r='42'/%3E%3Ccircle cx='50' cy='50' r='30' stroke-dasharray='2 3'/%3E%3Ccircle cx='50' cy='50' r='18'/%3E%3C/g%3E%3C/svg%3E") no-repeat;
}
.screen > * { position: relative; z-index: 1; }

.iconbtn { width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; color: var(--teal-text); border-radius: 22px; flex-shrink: 0; }
.iconbtn svg { width: 22px; height: 22px; }
.display { font-family: var(--serif); font-weight: 600; letter-spacing: -0.2px; }

/* ---------- list ---------- */
.lhead { display: flex; align-items: flex-end; justify-content: space-between; padding: calc(var(--safe-top) + 28px) 20px 0 22px; }
.lhead h1 { margin: 0; font-size: 38px; line-height: 1.05; }
.addbtn { width: 48px; height: 48px; border-radius: 24px; border: 1px solid var(--teal-soft); color: var(--teal-text); display: flex; align-items: center; justify-content: center; margin-bottom: 2px; }
.addbtn svg { width: 22px; height: 22px; }

.filters { position: sticky; top: 0; z-index: 3; background: var(--bg); padding: 18px 0 12px; display: flex; flex-direction: column; gap: 12px; }
.search { margin: 0 16px; height: 46px; border-radius: 23px; background: var(--card); box-shadow: inset 0 0 0 1px var(--line); display: flex; align-items: center; gap: 8px; padding: 0 6px 0 14px; color: var(--muted); }
.search > span svg { width: 18px; height: 18px; }
.search-in { flex: 1; min-width: 0; height: 100%; border: 0; outline: none; background: transparent; color: var(--ink); font: inherit; font-size: 16px; -webkit-appearance: none; appearance: none; }
.search-in::-webkit-search-cancel-button { display: none; }
.search:focus-within { box-shadow: inset 0 0 0 1.5px var(--teal); }
.clear { width: 36px; height: 36px; border-radius: 18px; display: flex; align-items: center; justify-content: center; color: var(--muted); }
.clear svg { width: 16px; height: 16px; }
.tags { display: flex; gap: 8px; overflow-x: auto; padding: 0 16px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.tags::-webkit-scrollbar { display: none; }
.tag { flex-shrink: 0; height: 34px; padding: 0 14px; border-radius: 17px; border: 1px solid var(--line); color: var(--ink-2); font-size: 14px; font-weight: 500; background: var(--card); white-space: nowrap; }
.tag.on { background: var(--btn); border-color: var(--btn); color: var(--on-teal); font-weight: 600; }

.hint { margin: 0; padding: 4px 20px calc(var(--safe-bottom) + 40px); font-size: 12px; color: var(--muted); text-align: center; opacity: 0.7; }
.none { margin: 24px 0 0; text-align: center; color: var(--muted); font-size: 15px; }
.none:empty { display: none; }
.rows { margin: 0 16px 14px; border-radius: 20px; background: var(--card); box-shadow: inset 0 0 0 1px var(--row-line), var(--shadow); overflow: hidden; }
.rows.enter .row { animation: rowIn 0.45s cubic-bezier(.2,.7,.2,1) both; animation-delay: calc(var(--i) * 35ms); }
@keyframes rowIn { from { opacity: 0; transform: translateY(10px); } }

.row { position: relative; touch-action: pan-y; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.row + .row .row-in::before { content: ''; position: absolute; top: 0; left: 18px; right: 18px; height: 1px; background: var(--row-line); }
.row-del { position: absolute; inset: 0; background: var(--danger); color: #fff; display: flex; align-items: center; justify-content: flex-end; padding-right: 22px; font-weight: 600; font-size: 15px; opacity: 0; }
.row.swiping .row-del { opacity: 1; }
.row-in { position: relative; width: 100%; min-height: 64px; text-align: start; display: flex; align-items: center; gap: 12px; padding: 13px 16px 13px 18px; background: var(--card); transition: transform 0.2s ease, background 0.15s ease; }
.row-in:active { background: var(--card-2); }
.row.swiping .row-in { transition: none; }
.row-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.row-title { font-family: var(--serif); font-size: 17.5px; font-weight: 600; line-height: 1.25; color: var(--ink); display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.row-sub { font-size: 13.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-tags { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12px; font-weight: 600; color: var(--teal-text); }
.row-blanks { flex-shrink: 0; font-size: 12px; font-weight: 600; color: var(--teal-text); background: var(--teal-wash); border-radius: 10px; padding: 3px 8px; font-variant-numeric: tabular-nums; }

.empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 24px; text-align: center; }
.empty p { margin: 0; color: var(--muted); font-size: 15px; }

/* ---------- using a prompt ---------- */
.uhead { position: sticky; top: 0; z-index: 3; background: var(--bg); display: flex; align-items: center; gap: 2px; padding: calc(var(--safe-top) + 6px) 8px 4px; }
.utitle { flex: 1; min-width: 0; font-family: var(--serif); font-size: 17px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: 0; transition: opacity 0.2s ease; }
.utitle.show { opacity: 1; }
.ubody { display: flex; flex-direction: column; gap: 14px; padding: 4px 16px calc(var(--safe-bottom) + 110px); }
.utitle-big { margin: 0 4px; font-size: 27px; line-height: 1.2; }
.ubody > .row-tags { margin: -6px 4px 0; font-size: 13px; }
.ptext { padding: 18px 18px 20px; font-size: 16px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--ink); -webkit-user-select: text; user-select: text; }
.pill { display: inline; font: inherit; font-weight: 600; color: var(--teal-text); background: var(--teal-wash); border-radius: 7px; padding: 1px 6px; box-shadow: inset 0 0 0 1px var(--teal-soft); -webkit-box-decoration-break: clone; box-decoration-break: clone; transition: background 0.15s ease, box-shadow 0.15s ease; }
.pill.empty { font-weight: 500; font-style: italic; box-shadow: inset 0 0 0 1px var(--teal); }
.pill.empty::before { content: '{'; opacity: 0.55; font-style: normal; }
.pill.empty::after { content: '}'; opacity: 0.55; font-style: normal; }
.pill.focus { background: var(--teal); color: var(--on-teal); box-shadow: none; }
.pill.small { font-size: 12.5px; padding: 2px 8px; }
.blanks .field label { width: 108px; overflow-wrap: anywhere; }
.ufoot { position: fixed; left: 0; right: 0; bottom: 0; z-index: 4; max-width: 560px; margin: 0 auto; display: flex; gap: 10px; padding: 28px 16px calc(var(--safe-bottom) + 18px); background: linear-gradient(to bottom, transparent, var(--bg) 40%); }
.copy { flex: 1; height: 58px; border-radius: 29px; background: var(--btn); color: var(--on-teal); display: flex; align-items: center; justify-content: center; gap: 10px; font-size: 17px; font-weight: 700; }
.copy svg { width: 20px; height: 20px; }
.copy.done { animation: pop 0.3s ease; }
.sharebtn { width: 58px; height: 58px; border-radius: 29px; border: 1.5px solid var(--teal); color: var(--teal-text); background: var(--bg); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.sharebtn svg { width: 22px; height: 22px; }
@keyframes pop { 50% { transform: scale(1.04); } }

/* ---------- editor ---------- */
.ehead { display: flex; align-items: center; justify-content: space-between; padding: calc(var(--safe-top) + 14px) 8px 8px; position: sticky; top: 0; background: var(--bg); z-index: 3; }
.ehead h1 { margin: 0; font-size: 19px; }
.txtbtn { height: 44px; padding: 0 12px; font-size: 16px; color: var(--muted); }
.txtbtn.quiet { align-self: center; font-size: 14px; }
.ehead .save { color: var(--teal-text); font-weight: 700; }
.ehead .save:disabled { color: var(--muted); opacity: 0.6; cursor: default; }
.ebody { display: flex; flex-direction: column; gap: 16px; padding: 8px 16px calc(var(--safe-bottom) + 40px); }
.pastebig { height: 200px; border-radius: 20px; border: 1.5px dashed var(--teal); background: var(--card-2); color: var(--teal-text); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; }
.pastebig svg { width: 40px; height: 40px; }
.pastebig b { font-size: 20px; }
.pastebig .sub { font-size: 13px; color: var(--muted); }
.section-label { font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: 1.1px; text-transform: uppercase; margin: 4px 4px -6px; }
.card { background: var(--card); border-radius: 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.field { display: flex; align-items: flex-start; gap: 10px; padding: 4px 14px 4px 16px; border-bottom: 1px solid var(--line); }
.field:last-child { border-bottom: 0; }
.field label { width: 96px; flex-shrink: 0; font-size: 15px; color: var(--muted); padding-top: 13px; }
.field textarea { flex: 1; min-width: 0; min-height: 48px; border: 0; outline: none; font: inherit; font-size: 16px; line-height: 1.45; background: transparent; color: var(--ink); resize: none; padding: 13px 0; overflow: hidden; }
.field textarea::placeholder, .textcard textarea::placeholder { color: var(--muted); opacity: 0.6; }
.textcard.edit { padding: 10px 8px 14px 16px; gap: 4px; }
.textcard-top { display: flex; align-items: center; gap: 8px; }
.textcard-top .section-label { flex: 1; font-size: 11px; margin: 0; }
.textcard textarea { width: 100%; min-height: 120px; border: 0; outline: none; background: transparent; color: var(--ink); resize: none; overflow: hidden; font: inherit; font-size: 16px; line-height: 1.55; padding: 0 8px 0 0; }
.blanksline { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding-top: 10px; margin-right: 8px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--muted); }
.tagpick { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-in { height: 34px; width: 120px; border-radius: 17px; border: 1px dashed var(--teal-soft); background: transparent; color: var(--ink); font: inherit; font-size: 14px; padding: 0 14px; outline: none; }
.tag-in:focus { border-style: solid; border-color: var(--teal); }
.danger { height: 52px; border-radius: 16px; color: var(--danger); background: var(--card); font-weight: 600; box-shadow: var(--shadow); margin-top: 10px; }
.note { font-size: 13px; color: var(--muted); margin: 0; line-height: 1.45; }

/* ---------- sign in ---------- */
.center { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 24px; text-align: center; }
.center .logo { width: 88px; height: 88px; border-radius: 22px; }
.center h1 { margin: 0; font-size: 38px; }
.center p { margin: 0; color: var(--muted); max-width: 320px; line-height: 1.5; }
.center code { font-size: 13px; background: var(--card); padding: 2px 6px; border-radius: 6px; }
.primary { height: 56px; padding: 0 28px; border-radius: 28px; background: var(--btn); color: var(--on-teal); font-size: 16px; font-weight: 700; display: inline-flex; align-items: center; gap: 10px; }
.primary svg { width: 22px; height: 22px; }
.primary:disabled { opacity: 0.6; }
.narrow { width: 100%; max-width: 300px; display: flex; flex-direction: column; gap: 6px; text-align: left; }
.narrow label { font-size: 13px; color: var(--muted); }
.narrow input { height: 48px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font: inherit; font-size: 16px; padding: 0 14px; }
.error { color: var(--danger) !important; min-height: 1.4em; }

/* ---------- toast ---------- */
#toast { position: fixed; left: 16px; right: 16px; bottom: calc(var(--safe-bottom) + 96px); max-width: 528px; margin: 0 auto; background: var(--toast-bg); color: var(--toast-ink); border-radius: 14px; padding: 4px 4px 4px 18px; min-height: 52px; display: flex; align-items: center; justify-content: space-between; gap: 8px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3); z-index: 20; font-size: 15px; }
#toast button { height: 44px; padding: 0 16px; font-weight: 700; color: var(--toast-act); }

/* ---------- feel ---------- */
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 0.22s; animation-timing-function: ease; }
.copy, .sharebtn, .primary, .tag, .addbtn, .iconbtn, .pastebig { transition: transform 0.12s ease, background 0.15s ease, opacity 0.15s ease; }
.copy:active, .sharebtn:active, .primary:active, .tag:active, .addbtn:active, .pastebig:active { transform: scale(0.96); }
.iconbtn:active { transform: scale(0.9); background: var(--card-2); }
.row-in:active { transform: scale(0.99); }

/* iOS has no vibrate API; toggling a hidden switch gives a light tap instead. */
.haptic { position: fixed; left: -100px; top: 0; width: 1px; height: 1px; overflow: hidden; opacity: 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
