/* PinOnce app shell (signed-in pages: Pin, Saved, Settings). iPhone-first, system type, true dark mode.
   One signature element: drafts and notes are paper notes held by a drawn push-pin. Everything else stays quiet.
   Loaded AFTER each page's own <style>, so these rules win. */

:root {
  --bg: #f2f2f7; --surface: #ffffff; --surface-2: #f7f7fa; --ink: #1d1d1f; --muted: #6e6e73; --line: #d8d8de;
  --accent: #c8372d; --accent-ink: #ffffff; --accent-soft: #fbe9e7; --ok: #1f7a46; --bad: #b3261e;
  --note: #fff6cc; --note-ink: #2a2414; --note-line: #eadf9f;
  --ui: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  --serif: ui-serif, "New York", "Iowan Old Style", Georgia, serif;
  --r: 14px; --tap: 44px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #000000; --surface: #1c1c1e; --surface-2: #2c2c2e; --ink: #f5f5f7; --muted: #98989f; --line: #38383a;
    --accent: #ff5a4a; --accent-ink: #ffffff; --accent-soft: #3a1714; --ok: #30d158; --bad: #ff6961;
    --note: #3b3522; --note-ink: #f3ecd2; --note-line: #574e30; }
}

html, body { background: var(--bg) !important; color: var(--ink) !important; }
body { font: 17px/1.45 var(--ui) !important; -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
a { color: var(--accent); }
h1 { font: 700 32px/1.15 var(--ui) !important; letter-spacing: -.02em; margin: 6px 0 4px !important; }
h2 { font: 600 13px/1.3 var(--ui) !important; text-transform: none !important; letter-spacing: 0 !important; color: var(--muted) !important; margin: 0 0 8px !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- bottom tab bar ---------- */
.ownnav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: space-around;
  padding: 6px 4px calc(6px + var(--safe-b)); border-top: .5px solid var(--line);
  background: color-mix(in srgb, var(--bg) 82%, transparent); -webkit-backdrop-filter: saturate(180%) blur(18px); backdrop-filter: saturate(180%) blur(18px); }
.ownnav a { flex: 1; display: grid; justify-items: center; gap: 2px; min-height: var(--tap); padding: 4px 0;
  text-decoration: none !important; color: var(--muted); font: 500 11px/1.1 var(--ui); border-radius: 10px; background: none !important; }
.ownnav svg { width: 26px; height: 26px; }
.ownnav a.on { color: var(--accent); }
body:has(.ownnav) .wrap { padding-bottom: calc(96px + var(--safe-b)) !important; }

/* ---------- Pin (chat) page: composer above the tab bar ---------- */
body:has(#log) { display: flex; flex-direction: column; height: 100dvh !important; }
#log { gap: 10px !important; padding: 14px 16px 10px !important; }
#login { order: 0; } #log { order: 1; } footer#foot { order: 2; } #nav { order: 3; }
body:has(#log) .ownnav { position: static; }
.msg { font-size: 17px !important; line-height: 1.42 !important; padding: 10px 14px !important; border-radius: 20px !important; max-width: 84% !important; }
.msg.pin { background: var(--surface) !important; border: 0 !important; border-bottom-left-radius: 6px !important; box-shadow: 0 .5px 0 var(--line); }
.msg.pin::before { content: none !important; }
.msg.me { background: var(--accent) !important; color: var(--accent-ink) !important; border-bottom-right-radius: 6px !important; }
.msg.me a { color: var(--accent-ink); }
.msg.me img, .msg.me video { border-radius: 14px !important; }
.thinking { color: var(--muted) !important; font-style: normal !important; }
.thinking::after { content: ""; display: inline-block; width: 1.2em; text-align: left; animation: dots 1.2s steps(4) infinite; }
@keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }
.chips { flex-wrap: nowrap !important; overflow-x: auto; max-width: calc(100% + 32px) !important; margin: 0 -16px; padding: 2px 16px 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; min-height: 40px; border: 0 !important; background: var(--surface) !important; color: var(--ink) !important;
  font: 500 15px var(--ui) !important; padding: 9px 16px !important; border-radius: 999px !important; box-shadow: inset 0 0 0 .5px var(--line); }
.chip.main { background: var(--accent) !important; color: var(--accent-ink) !important; box-shadow: none; }
.chip:active { transform: scale(.97); }
footer#foot { background: var(--bg) !important; border-top: 0 !important; padding: 8px 12px 8px !important; }
.bar { align-items: center !important; gap: 8px !important; }
.round { width: var(--tap) !important; height: var(--tap) !important; display: grid; place-items: center; padding: 0;
  background: var(--surface) !important; color: var(--ink) !important; box-shadow: inset 0 0 0 .5px var(--line) !important; }
.round svg { width: 22px; height: 22px; }
.round.send { background: var(--accent) !important; color: var(--accent-ink) !important; box-shadow: none !important; }
.round.rec { background: var(--accent) !important; color: var(--accent-ink) !important; }
textarea#say { min-height: var(--tap) !important; border-radius: 22px !important; border: 0 !important; background: var(--surface) !important;
  box-shadow: inset 0 0 0 .5px var(--line); font: 17px/1.35 var(--ui) !important; padding: 11px 16px !important; color: var(--ink) !important; }

/* the signature: a paper note held by a push-pin (drafts; notes on the creator's page share the idea) */
.draft { width: min(360px, 88%) !important; background: var(--note) !important; color: var(--note-ink) !important;
  border-radius: 3px !important; padding: 22px 18px 14px !important; transform: rotate(-.8deg) !important;
  box-shadow: 0 1px 1px rgba(0,0,0,.06), 0 10px 22px -12px rgba(0,0,0,.35) !important; margin: 10px 0 4px; }
.draft::before { content: "" !important; position: absolute; top: -12px; left: 50%; width: 30px; height: 34px; margin-left: -15px;
  border-radius: 0 !important; box-shadow: none !important;
  background: no-repeat center/contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 34'%3E%3Cpath d='M15 22 L15 33' stroke='%238e8e93' stroke-width='2' stroke-linecap='round'/%3E%3Cellipse cx='15' cy='22' rx='9' ry='3' fill='%23a3271e'/%3E%3Cpath d='M9 21 L11 10 L19 10 L21 21 Z' fill='%23c8372d'/%3E%3Cellipse cx='15' cy='9' rx='9' ry='6' fill='%23d9493d'/%3E%3Cellipse cx='12' cy='7' rx='3' ry='1.6' fill='%23ffffff' opacity='.55'/%3E%3C/svg%3E") !important; }
.draft h3 { font: 600 21px/1.25 var(--serif) !important; margin: 0 0 4px !important; }
.draft .meta, .draft .to { font: 14px/1.4 var(--ui) !important; opacity: .75; }
.draft .body { font: 16px/1.5 var(--serif) !important; }
.draft .ph img, .draft .ph video { border-radius: 2px !important; height: 132px !important; }
.result a.card { background: var(--surface) !important; border: 0 !important; border-radius: var(--r) !important; box-shadow: inset 0 0 0 .5px var(--line); }

/* sign-in */
#login input { min-height: var(--tap); border-radius: 12px !important; border: 0 !important; background: var(--surface) !important; box-shadow: inset 0 0 0 .5px var(--line); font: 17px var(--ui) !important; }

/* ---------- Settings & Saved: grouped lists ---------- */
.wrap { gap: 22px !important; }
.box { background: var(--surface) !important; border: 0 !important; border-radius: var(--r) !important; padding: 14px 16px !important; box-shadow: none !important; }
.note-txt, .muted, .note-txt a { color: var(--muted) !important; font-size: 14px !important; }
label { font: 500 15px var(--ui) !important; }
input, textarea, select { font: 17px var(--ui) !important; color: var(--ink) !important; background: var(--surface-2) !important; border: 0 !important;
  border-radius: 10px !important; min-height: var(--tap); box-shadow: inset 0 0 0 .5px var(--line); }
input[type=checkbox], input[type=radio] { min-height: 0; box-shadow: none; accent-color: var(--accent); width: 20px !important; height: 20px; }
.go, .save { background: var(--accent) !important; color: var(--accent-ink) !important; border: 0 !important; border-radius: 12px !important;
  min-height: var(--tap); padding: 0 20px !important; font: 600 17px var(--ui) !important; }
.small, .tag, .bar button, .search button { background: var(--surface-2) !important; color: var(--ink) !important; border: 0 !important;
  border-radius: 10px !important; min-height: 36px; font: 500 15px var(--ui) !important; box-shadow: inset 0 0 0 .5px var(--line); }
.linkbtn { color: var(--accent) !important; font: 15px var(--ui) !important; text-decoration: none !important; }
.conn { padding: 12px 0 !important; border-top: .5px solid var(--line) !important; }
.conn:first-child { border-top: 0 !important; }
.conn summary { list-style: none; display: flex; align-items: center; gap: 6px; min-height: 32px; font: 600 17px var(--ui) !important; }
.conn summary::-webkit-details-marker { display: none; }
.conn summary::after { content: ""; margin-left: auto; width: 8px; height: 8px; border-right: 2px solid var(--line); border-bottom: 2px solid var(--line); transform: rotate(-45deg); }
.conn[open] summary::after { transform: rotate(45deg); }
.conn .state { font: 400 15px var(--ui) !important; color: var(--muted) !important; }
.conn .state.on { color: var(--ok) !important; }
.wrap .pin { border-top: .5px solid var(--line) !important; padding: 12px 0 !important; }
.wrap .pin:first-child { border-top: 0 !important; }
.wrap .pin .pic, .wrap .pin .ico { border-radius: 10px !important; }
.chip.done { color: var(--ok) !important; } .chip.failed { color: var(--bad) !important; }
.meter .bar { background: var(--surface-2) !important; height: 6px !important; }
#formfold summary { list-style: none; color: var(--accent); font: 500 16px var(--ui) !important; }
#formfold summary::-webkit-details-marker { display: none; }
.item { background: var(--surface) !important; border: 0 !important; border-radius: var(--r) !important; }
.item .n { background: var(--note) !important; color: var(--note-ink) !important; font-family: var(--serif) !important; }

/* ---------- desktop and tablet: navigation becomes a left sidebar, content a centered column ---------- */
@media (min-width: 900px) {
  .ownnav { top: 0; bottom: 0; right: auto; width: 220px; flex-direction: column; justify-content: flex-start; gap: 4px;
    padding: 28px 12px; border-top: 0; border-right: .5px solid var(--line); background: var(--bg); -webkit-backdrop-filter: none; backdrop-filter: none; }
  .ownnav::before { content: "PinOnce"; font: 600 22px var(--serif); color: var(--ink); padding: 0 12px 18px; }
  .ownnav a { flex: none; display: flex; align-items: center; gap: 12px; justify-items: start; padding: 10px 12px; font: 500 16px var(--ui); color: var(--ink); }
  .ownnav a svg { width: 22px; height: 22px; color: var(--muted); }
  .ownnav a.on { background: var(--surface) !important; color: var(--accent); }
  .ownnav a.on svg { color: var(--accent); }
  body:has(.ownnav) { padding-left: 220px; }
  body:has(.ownnav) .wrap { padding-bottom: 48px !important; max-width: 760px !important; }
  body:has(#log) .ownnav { position: fixed; }
  #log, .bar { max-width: 760px !important; }
  .msg { max-width: 70% !important; }
}
.conn p > .go { display: block; margin: 6px 0 10px; }
#who { margin: 0 !important; }

/* Settings: the cards inside the signed-in area are spaced like the rest of the page */
body:has(#plan) .wrap > #app:not([hidden]) { display: grid; gap: 22px; }

/* ---------- plan and storage (Settings) + "storage full" card (Pin chat) ---------- */
#plan .planhead { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
#plan .planname { font: 600 22px/1.2 var(--ui); letter-spacing: -.01em; }
#plan .planprice { font: 15px var(--ui); color: var(--muted); }
#plan .meter { gap: 6px; font: 14px var(--ui); color: var(--muted); }
#plan .fullnote { margin: 12px 0 0; padding: 10px 12px; border-radius: 10px; background: var(--accent-soft); color: var(--ink); font: 15px/1.4 var(--ui); }
#plan .planinfo { margin: 10px 0 0; }
#plan .planact { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 14px; }
#plan .planact:not(:has(button:not([hidden]))) { display: none; }
#plan .planact .go { flex: 1 1 auto; }
#plan .planact .small { min-height: var(--tap); padding: 0 16px; }
#plan #upnote { margin: 8px 0 0; }
#plan .msg:empty { display: none; }
#plan .msg { display: block; margin-top: 10px; }
.msg.fullcard { max-width: min(340px, 88%) !important; white-space: normal !important; padding: 14px 16px !important; }
.fullcard .full-h { font: 600 19px/1.25 var(--ui); margin-bottom: 10px; }
.fullcard p { margin: 10px 0 0; }
.fullcard .full-up { color: var(--muted); font-size: 15.5px; }
.fullcard .full-up b { color: var(--ink); }
.fullcard .meter .bar { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.fullcard .meter .bar span { display: block; height: 100%; border-radius: 99px; background: var(--bad); }
