/* Layout: a one-screen memo thread. Oldest on top, newest at the bottom, the input bar pinned under it.
   Light base; colors come from the Tide icon: navy for text, mid-blue for memos and actions, aqua for the main buttons. */
:root {
  --ground: #f2f6fb;     /* page, a pale blue-white */
  --surface: #ffffff;    /* header, input bar, cards */
  --field: #f7f9fc;
  --line: #d8e2ef;
  --navy: #082556;       /* icon background: headings and body text */
  --wave: #0b5092;       /* icon's outer waves: actions, links */
  --bubble: #e3eefa;     /* light tint of the wave blue */
  --aqua: #40ecd6;       /* icon's middle wave: send, unlock */
  --aqua-deep: #14b8a6;  /* focus ring, readable on white */
  --ink: #12274a;
  --muted: #62738f;
  --danger: #c2363f;
  --font-ui: "Hiragino Sans", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  --font-brand: "Arial Rounded MT Bold", "Hiragino Maru Gothic ProN", "Varela Round", "Segoe UI", system-ui, sans-serif;
  --font-mono: "Cascadia Mono", "Consolas", "Menlo", "Hiragino Sans", "Yu Gothic UI", monospace;
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--ground); color: var(--ink);
  font-family: var(--font-ui); font-size: 15px; line-height: 1.55;
  padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px);
}
.app { height: 100%; display: flex; flex-direction: column; }
.gut {
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.col { max-width: 720px; margin-inline: auto; width: 100%; }
:focus-visible { outline: 2px solid var(--aqua-deep); outline-offset: 2px; }

/* brand */
.brand { display: flex; align-items: center; gap: 10px; }
.brand img { display: block; border-radius: 7px; }
h1 { font-family: var(--font-brand); font-size: 19px; font-weight: 700; margin: 0; letter-spacing: .04em; color: var(--navy); }

/* gate */
.gate { height: 100%; display: flex; align-items: center; justify-content: center; padding: 16px; }
.gatebox {
  width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
  padding: 28px 24px 22px; display: flex; flex-direction: column; gap: 10px;
  box-shadow: 0 10px 30px rgba(8, 37, 86, .08);
}
.gatebrand { flex-direction: column; gap: 10px; margin-bottom: 12px; }
.gatebrand img { border-radius: 14px; }
.gatebrand h1 { font-size: 24px; }
.gatebox label[for] { font-size: 12.5px; color: var(--muted); letter-spacing: .03em; margin-bottom: -4px; }
.gatebox input[type="password"], .gatebox input[type="text"] {
  font: inherit; font-size: 16px; color: var(--ink); background: var(--field);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%;
}
.gatebox input[type="password"]:focus, .gatebox input[type="text"]:focus {
  border-color: var(--aqua-deep); outline: none; box-shadow: 0 0 0 3px rgba(20, 184, 166, .15);
}
.check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--muted); margin-top: 2px; }
.check input { accent-color: var(--wave); width: 16px; height: 16px; margin: 0; }
.err { margin: 0; min-height: 1.5em; font-size: 13.5px; color: var(--danger); text-align: center; }
button.primary {
  font: inherit; font-weight: 700; letter-spacing: .03em; cursor: pointer; min-height: 46px; margin-top: 6px;
  background: var(--aqua); color: var(--navy); border: 0; border-radius: 999px;
}
button.primary:hover { filter: brightness(.96); }
button.link { font: inherit; font-size: 12.5px; color: var(--muted); background: none; border: 0; cursor: pointer; padding: 4px 2px; }
button.link:hover { color: var(--wave); }

/* header */
header { background: var(--surface); border-bottom: 1px solid var(--line); padding-block: 10px; flex: none; }
header .col { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 16px; }
.headright { display: flex; align-items: center; gap: 14px; }
.device { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12.5px; }
.device input {
  font: inherit; color: var(--ink); background: transparent; border: 0; border-bottom: 1px dashed var(--line);
  width: 8.5em; padding: 1px 2px;
}
.device input:focus { outline: none; border-bottom-color: var(--wave); }

/* thread */
#scroll { flex: 1 1 0; min-height: 0; overflow-y: auto; padding-block: 14px; }
#list { display: flex; flex-direction: column; gap: 12px; list-style: none; margin: 0; padding: 0; }
.day {
  align-self: center; font-size: 11.5px; color: var(--muted); letter-spacing: .04em;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 999px; padding: 1px 12px; margin-block: 4px; font-variant-numeric: tabular-nums;
}
.msg { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; min-width: 0; }
.bubble {
  max-width: min(86%, 520px); min-width: 0;
  background: var(--bubble); color: var(--ink);
  border-radius: 18px 18px 5px 18px; padding: 9px 13px;
}
.text {
  font-family: var(--font-mono); font-size: 14px; line-height: 1.6; margin: 0;
  white-space: pre-wrap; overflow-wrap: anywhere; max-height: 22em; overflow: auto;
}
.text a { color: var(--wave); text-decoration: underline; text-underline-offset: 2px; }
.bubble.pic { padding: 4px; }
.bubble.pic img { display: block; max-width: 100%; max-height: 260px; border-radius: 14px 14px 3px 14px; }
.bubble.pic .cap { padding: 4px 9px 3px; font-size: 12.5px; overflow-wrap: anywhere; color: var(--muted); }
.file { display: flex; align-items: center; gap: 11px; min-width: 0; }
.file .ext {
  width: 44px; height: 44px; flex: none; border-radius: 11px; background: var(--surface); color: var(--wave);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: 11px; font-weight: 600; text-transform: uppercase;
}
.file .info { min-width: 0; }
.file .name { font-weight: 600; overflow-wrap: anywhere; min-width: 0; color: var(--navy); }
.size { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.foot {
  display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 0 12px;
  font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; padding-right: 4px;
}
.foot button, .foot a {
  font: inherit; color: var(--wave); font-weight: 600; background: none; border: 1px solid transparent; cursor: pointer;
  padding: 2px 2px; min-height: 28px; text-decoration: none; display: inline-flex; align-items: center; border-radius: 999px;
}
.foot button.del { color: var(--muted); font-weight: 500; }
.foot button.del.armed { color: var(--danger); font-weight: 700; border-color: currentColor; padding: 2px 10px; }
.foot button:disabled { opacity: .5; cursor: default; }
.empty { color: var(--muted); text-align: center; padding: 48px 8px; }
.empty strong { color: var(--navy); display: block; margin-bottom: 4px; }

#status { flex: none; font-size: 12.5px; color: var(--muted); padding-block: 2px; }
#status.err { color: var(--danger); }
#status .col { text-align: right; }

/* input bar */
.bar { flex: none; background: var(--surface); border-top: 1px solid var(--line); padding-block: 10px 6px; }
.bar.over { background: var(--bubble); }
.bar .col { display: flex; align-items: flex-end; gap: 8px; }
.bar .usage { justify-content: flex-end; font-size: 11px; color: var(--muted); padding-top: 3px; min-height: 1.4em; font-variant-numeric: tabular-nums; }
.round {
  flex: none; width: 42px; height: 42px; border-radius: 50%; cursor: pointer; position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); background: var(--surface); color: var(--navy); font: inherit; font-size: 22px; line-height: 1;
}
.round:hover { border-color: var(--wave); color: var(--wave); }
.round.send { background: var(--aqua); border-color: var(--aqua); color: var(--navy); font-size: 17px; }
.round.send:hover { filter: brightness(.96); color: var(--navy); }
.round input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.round:focus-within { outline: 2px solid var(--aqua-deep); outline-offset: 2px; }
textarea {
  flex: 1 1 0; min-width: 0; resize: none; height: 42px; max-height: 160px;
  font-family: var(--font-ui); font-size: 16px; line-height: 1.4;
  color: var(--ink); background: var(--field); border: 1px solid var(--line); border-radius: 21px; padding: 9px 15px;
}
textarea::placeholder { color: #8a99b0; }
textarea:focus { outline: none; border-color: var(--aqua-deep); }

/* pinned strip */
.pins { flex: none; background: var(--surface); border-bottom: 1px solid var(--line); padding-block: 7px; }
.pins .col { display: flex; align-items: center; gap: 10px; min-width: 0; }
.pinlabel { flex: none; font-size: 11.5px; font-weight: 700; color: var(--wave); letter-spacing: .04em; }
.pinlist { display: flex; gap: 6px; overflow-x: auto; min-width: 0; scrollbar-width: none; }
.pinlist::-webkit-scrollbar { display: none; }
.chip {
  flex: none; max-width: 16em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font: inherit; font-size: 12.5px; color: var(--navy); background: var(--bubble); border: 1px solid transparent;
  border-radius: 999px; padding: 3px 11px; cursor: pointer;
}
.chip:hover { border-color: var(--wave); }
.chip.filechip { background: var(--field); border-color: var(--line); }
.pinmark { color: var(--wave); font-weight: 700; }
.msg.flash .bubble { animation: flash 1.4s ease-out; }
@keyframes flash { 0% { box-shadow: 0 0 0 3px var(--aqua); } 100% { box-shadow: 0 0 0 3px transparent; } }

/* inline editor */
.editor { width: min(100%, 560px); display: flex; flex-direction: column; gap: 6px; }
.editfield {
  flex: none; width: 100%; height: auto; font-family: var(--font-mono); font-size: 14px; line-height: 1.6; color: var(--ink);
  background: var(--surface); border: 1px solid var(--aqua-deep); border-radius: 14px; padding: 9px 13px;
  box-shadow: 0 0 0 3px rgba(20, 184, 166, .12); resize: vertical; min-height: 44px; max-height: 320px;
}
input.editfield { font-family: var(--font-ui); font-size: 15px; resize: none; }
.editfield:focus { outline: none; border-color: var(--aqua-deep); }
.editrow { display: flex; justify-content: flex-end; align-items: center; gap: 8px; }
.edithint { font-size: 11.5px; color: var(--muted); margin-right: auto; }
.ghost, .solid {
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; border-radius: 999px; padding: 5px 14px; min-height: 32px;
}
.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.solid { background: var(--aqua); color: var(--navy); border: 1px solid var(--aqua); }
.ghost:disabled, .solid:disabled { opacity: .5; cursor: default; }

/* file list sheet */
.sheet {
  position: fixed; inset: 0; z-index: 20; background: rgba(8, 37, 86, .28);
  display: flex; align-items: flex-end; justify-content: center;
  padding-top: env(safe-area-inset-top, 0px);
}
.sheetbox {
  width: 100%; max-width: 720px; max-height: 82vh; display: flex; flex-direction: column;
  background: var(--surface); border-radius: 18px 18px 0 0; box-shadow: 0 -10px 30px rgba(8, 37, 86, .15);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
@media (min-width: 760px) { .sheet { align-items: center; } .sheetbox { border-radius: 18px; max-height: 80vh; } }
.sheethead { display: flex; align-items: baseline; gap: 10px; padding: 16px 18px 12px; border-bottom: 1px solid var(--line); }
.sheethead h2 { font-size: 16px; margin: 0; color: var(--navy); }
.sheetsum { font-size: 12px; color: var(--muted); margin-right: auto; font-variant-numeric: tabular-nums; }
.filelist { list-style: none; margin: 0; padding: 4px 0; overflow-y: auto; }
.filerow { display: flex; align-items: center; gap: 11px; padding: 9px 18px; border-bottom: 1px solid var(--field); min-width: 0; }
.filerow .ext {
  width: 40px; height: 40px; flex: none; border-radius: 10px; background: var(--bubble); color: var(--wave);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 600; text-transform: uppercase;
}
.filerow .info { flex: 1 1 auto; min-width: 0; }
.filerow .name { font-weight: 600; color: var(--navy); overflow-wrap: anywhere; }
.fmeta { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.facts { flex: none; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0 10px; font-size: 12.5px; }
.facts button, .facts a {
  font: inherit; color: var(--wave); font-weight: 600; background: none; border: 1px solid transparent; cursor: pointer;
  padding: 2px 2px; min-height: 28px; text-decoration: none; display: inline-flex; align-items: center; border-radius: 999px;
}
.facts button.del { color: var(--muted); font-weight: 500; }
.facts button.del.armed { color: var(--danger); font-weight: 700; border-color: currentColor; padding: 2px 10px; }
.sheetempty { color: var(--muted); text-align: center; padding: 32px 16px; margin: 0; }
@media (max-width: 480px) { .filerow { flex-wrap: wrap; } .facts { width: 100%; padding-left: 51px; justify-content: flex-start; } }
@media (prefers-reduced-motion: reduce) { .msg.flash .bubble { animation: none; } }
