:root {
  color-scheme: light dark;
  font: 16px/1.5 system-ui, sans-serif;
  --paper: #f4f6f1;
  --card: #fff;
  --ink: #172a25;
  --muted: #4c625a;
  --line: #dce5dc;
  --green: #215346;
  --user: #e2eee5;
  --danger: #942e2a;
}
@media (prefers-color-scheme: dark) {
  :root { --paper: #141d1a; --card: #22312c; --ink: #e8f4ec; --muted: #aec4b7; --line: #3a5147; --green: #275b4b; --user: #254239; --danger: #ffc2b9; }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--paper); color: var(--ink); }
main { margin: auto; max-width: 680px; padding: 0 12px max(16px, env(safe-area-inset-bottom)); }
.top { position: sticky; top: 0; z-index: 2; background: var(--paper); padding: 6px 0; margin-bottom: 8px; border-bottom: 1px solid var(--line); }
.toolbar { display: flex; align-items: center; gap: 6px; }
.toolbar + .toolbar { margin-top: 4px; }
.title { display: grid; flex: 1; min-width: 0; }
.title strong { font-size: 17px; line-height: 1.15; }
#status { color: var(--muted); font-size: 12px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
h1 { flex: 1; min-width: 0; margin: 0; font-size: 17px; line-height: 1.2; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
button { font: inherit; font-weight: 650; color: white; min-height: 44px; padding: 8px 14px; cursor: pointer; border: 0; border-radius: 10px; background: var(--green); }
button.quiet { color: var(--ink); background: var(--card); border: 1px solid var(--line); }
button.danger { color: var(--danger); }
button:disabled { opacity: .48; cursor: default; }
.tool-button { position: relative; display: inline-grid; place-items: center; flex: 0 0 auto; width: 44px; height: 44px; padding: 0; font-size: 20px; line-height: 1; -webkit-touch-callout: none; user-select: none; }
.tool-button::after { content: attr(data-tooltip) / ""; display: none; position: absolute; z-index: 1; top: calc(100% + 4px); right: 0; width: max-content; max-width: calc(100vw - 24px); padding: 5px 8px; border-radius: 6px; background: var(--ink); color: var(--paper); font-size: 12px; line-height: 1.3; pointer-events: none; }
.tool-button:focus-visible::after, .tool-button[data-hint]::after { display: block; }
@media (hover: hover) {
  .tool-button:hover::after { display: block; }
}
#back::after { right: auto; left: 0; }
.copy-row { display: flex; justify-content: flex-end; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
#copy-last::after { top: auto; bottom: calc(100% + 4px); }
.copy-icon { position: relative; width: 12px; height: 14px; margin: 3px 0 0 3px; border: 1.5px solid currentColor; border-radius: 2px; }
.copy-icon::before { content: ""; position: absolute; top: -5px; left: -5px; width: 10px; height: 12px; border: 1.5px solid currentColor; border-width: 1.5px 0 0 1.5px; border-radius: 2px 0 0; }
#entries { overflow: hidden; border-radius: 14px; }
.entry { display: flex; align-items: center; gap: 10px; width: 100%; padding: 12px 14px; text-align: left; background: var(--card); color: var(--ink); border-radius: 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.entry i { font-style: normal; margin-left: auto; color: var(--muted); }
.shortcut { margin-top: 12px; border: 1px solid var(--line); border-radius: 12px; }
dialog { max-width: min(430px, calc(100vw - 32px)); width: 100%; padding: 18px; border: 1px solid var(--line); border-radius: 16px; color: var(--ink); background: var(--paper); }
dialog::backdrop { background: #10251c88; }
dialog h2 { margin: 0 0 14px; }
dialog label { display: block; margin-top: 10px; }
dialog select, dialog input { width: 100%; padding: 10px; font: inherit; background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: 9px; }
dialog .controls { margin-top: 18px; }
#manage-content { display: grid; gap: 8px; }
#manage-content p { margin: 0; overflow-wrap: anywhere; }
#manage-content .quiet { text-align: left; }
.pages, .controls { display: flex; gap: 8px; justify-content: flex-end; }
.pages { gap: 6px; }
#messages { display: grid; gap: 10px; margin: 12px 0; }
.message, #notice { margin: 0; padding: 12px 14px; background: var(--card); border-radius: 14px; border: 1px solid var(--line); }
.message.user { margin-left: 8%; background: var(--user); }
.message span { color: var(--muted); font-weight: 700; font-size: 13px; }
.message p { margin: 4px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
#notice { margin-bottom: 12px; }
#composer { position: sticky; bottom: 0; padding: 10px 0 max(8px, env(safe-area-inset-bottom)); background: var(--paper); }
textarea { display: block; width: 100%; resize: vertical; font: inherit; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin-bottom: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
