/* flff shell: the same tokens as www.flff.fi and the sign-in pages. */
:root {
  --bg: #fafaf9; --fg: #1c1917; --muted: #57534e; --line: #e7e5e4; --card: #ffffff;
  --accent: #4f46e5; --accent-fg: #ffffff; --hover: #f5f5f4; --current: #eef2ff; --error: #b91c1c;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #1c1917; --fg: #f5f5f4; --muted: #a8a29e; --line: #44403c; --card: #292524;
          --accent: #818cf8; --accent-fg: #1c1917; --hover: #292524; --current: #1e1b4b; --error: #f87171; }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0; display: grid; grid-template-columns: minmax(18rem, 22rem) 1fr; background: var(--bg); color: var(--fg);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (max-width: 760px) {
  body { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .side { max-height: 45vh; border-right: 0; border-bottom: 1px solid var(--line); }
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, select { font: inherit; }

/* sidebar */
.side { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); }
.bar { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .75rem 1rem; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; color: var(--fg); letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
#site-switch { min-width: 0; max-width: 12rem; padding: .3rem .5rem; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--fg); }
main { flex: 1; overflow-y: auto; padding: 1rem; min-height: 0; }
.center { text-align: center; margin-top: 3rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
h1.title { font-size: 1.2rem; margin: .25rem 0 1rem; letter-spacing: -.01em; }

.signin { text-align: center; padding: 2.5rem .5rem; }
.signin h1 { font-size: 1.25rem; margin: 0 0 .5rem; letter-spacing: -.01em; }
button.primary { background: var(--accent); color: var(--accent-fg); border: 0; border-radius: 8px; padding: .65rem 1.2rem; font-weight: 600; margin: 1rem 0; cursor: pointer; }
.notice { border: 1px solid var(--line); border-radius: 12px; padding: 1rem; background: var(--card); }
.notice.error p { color: var(--error); margin-top: 0; }
.notice.free { margin: 0 0 .9rem; padding: .55rem .75rem; font-size: .85rem; border-color: #f59e0b; background: #fffbeb; color: #78350f; }
@media (prefers-color-scheme: dark) { .notice.free { background: #2b2112; color: #fcd34d; border-color: #b45309; } }
.notice button { background: none; border: 1px solid var(--line); border-radius: 8px; padding: .4rem .9rem; color: var(--fg); cursor: pointer; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin-bottom: 1rem; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: .5rem .6rem; }
.stat .label { color: var(--muted); font-size: .75rem; }
.stat .value { font-size: 1.05rem; font-weight: 650; letter-spacing: -.02em; }

.crumbs { font-size: .9rem; margin-bottom: .4rem; word-break: break-all; }
.crumbs .sep { color: var(--muted); margin: 0 .25rem; }
.list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--card); }
.list li { position: relative; display: grid; grid-template-columns: 1rem 1fr auto 4.8rem; gap: .45rem; align-items: center; padding: .4rem .65rem; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.list li:hover { background: var(--hover); }
.list li.current { background: var(--current); }
.list .icon { color: var(--muted); font-size: .8rem; text-align: center; }
.list .name { color: var(--fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .dir .name { font-weight: 600; }
.list .meta { color: var(--muted); font-size: .78rem; text-align: right; white-space: nowrap; }

.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: .6rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: .75rem .9rem; }
.card-title { font-weight: 650; font-size: 1.05rem; }

.foot { display: flex; justify-content: space-between; gap: .75rem; padding: .6rem 1rem; border-top: 1px solid var(--line); font-size: .8rem; color: var(--muted); }
.who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* preview */
.stage { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }
.address { display: flex; align-items: center; gap: .5rem; padding: .55rem 1rem; border-bottom: 1px solid var(--line); font: .85rem/1.4 ui-monospace, "Cascadia Code", Menlo, Consolas, monospace; color: var(--muted); }
#address-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.panes { flex: 1; display: flex; min-height: 0; }
#preview { flex: 1; width: 100%; min-width: 0; border: 0; background: #fff; }
.editing .panes > .editor, .editing #preview, .brain-open .panes > .brain, .brain-open #preview { flex: 1 1 0; }
@media (max-width: 1100px) { .editing .panes, .brain-open .panes { flex-direction: column; } }
.placeholder { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--muted); opacity: .8; }

/* file actions: over the size and date on hover or keyboard focus; on touch
   screens always shown, in place of the size and date */
.acts { display: none; gap: .25rem; position: absolute; right: .5rem; top: 50%; transform: translateY(-50%);
  padding-left: .5rem; background: var(--hover); }
.list li.current .acts { background: var(--current); }
.list li:hover .acts, .list li:focus-within .acts { display: flex; }
@media (hover: none) {
  .list li { grid-template-columns: 1rem 1fr auto; }
  .list .meta { display: none; }
  .acts { display: flex; position: static; transform: none; padding: 0; background: none; }
}
button.act { background: none; border: 1px solid var(--line); border-radius: 6px; padding: .05rem .4rem; font-size: .75rem; color: var(--fg); cursor: pointer; }
button.act:hover { background: var(--card); border-color: var(--muted); }
button.act.danger { color: var(--error); }
.tools { display: flex; flex-wrap: wrap; gap: .35rem; margin: .1rem 0 .5rem; }
button.tool { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: .25rem .65rem; font-size: .82rem; color: var(--fg); cursor: pointer; }
button.tool:hover { border-color: var(--muted); }
.status { min-height: 1.2em; margin: .4rem 0 0; color: var(--muted); }
.status.ok, .editor-status.ok { color: #15803d; }
.status.error, .editor-status.error { color: var(--error); }
@media (prefers-color-scheme: dark) { .status.ok, .editor-status.ok { color: #4ade80; } }
body.dropping .side { outline: 3px dashed var(--accent); outline-offset: -6px; }
body.dropping .side::after { content: "Drop to upload into this folder"; position: fixed; left: 1rem; bottom: 3.2rem; padding: .4rem .7rem;
  border-radius: 8px; background: var(--accent); color: var(--accent-fg); font-weight: 600; font-size: .85rem; }

/* history */
.history { margin-top: 1rem; border: 1px solid var(--line); border-radius: 10px; background: var(--card); padding: .6rem .75rem; }
.history-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .3rem; }
ul.versions { list-style: none; margin: 0; padding: 0; max-height: 18rem; overflow-y: auto; }
ul.versions li { padding: .35rem 0; border-top: 1px solid var(--line); }
ul.versions li:first-child { border-top: 0; }
ul.versions .act { margin-left: .4rem; }
.v-change { font-size: .85rem; word-break: break-all; }

/* editor: a transparent textarea over a highlighted copy of its text */
.editor { display: flex; flex-direction: column; min-width: 0; min-height: 0; border-right: 1px solid var(--line); background: var(--card); }
.editor-bar { display: flex; align-items: center; gap: .5rem; padding: .4rem .6rem; border-bottom: 1px solid var(--line); }
.editor-name { font: 600 .85rem/1.4 ui-monospace, "Cascadia Code", Menlo, Consolas, monospace; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.editor-status { flex: 1; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
button.small-btn { margin: 0; padding: .3rem .9rem; font-size: .85rem; }
button.primary:disabled { opacity: .45; cursor: default; }
.editor-versions { max-height: 40%; overflow-y: auto; padding: .4rem .75rem; border-bottom: 1px solid var(--line); }
.code { position: relative; flex: 1; min-height: 12rem; }
.code pre, .code textarea {
  position: absolute; inset: 0; margin: 0; padding: .75rem .9rem; border: 0; tab-size: 2;
  font: 13px/1.55 ui-monospace, "Cascadia Code", Menlo, Consolas, monospace; white-space: pre; overflow-wrap: normal;
}
.code pre { overflow: hidden; pointer-events: none; color: var(--fg); }
.code textarea { width: 100%; height: 100%; resize: none; overflow: auto; background: transparent; color: transparent;
  caret-color: var(--fg); outline: none; }
.code textarea::selection { background: rgba(79, 70, 229, .25); color: transparent; }

/* Prism tokens, light and dark */
.token.comment, .token.prolog, .token.doctype, .token.cdata { color: #6b7280; font-style: italic; }
.token.tag, .token.selector, .token.important, .token.keyword { color: #7c3aed; }
.token.attr-name, .token.property, .token.function { color: #0369a1; }
.token.attr-value, .token.string, .token.url, .token.char { color: #15803d; }
.token.number, .token.boolean, .token.constant, .token.unit { color: #b45309; }
.token.punctuation, .token.operator { color: #57534e; }
.token.entity, .token.regex, .token.variable { color: #be185d; }
.token.title, .token.bold { font-weight: 700; }
.token.italic { font-style: italic; }
@media (prefers-color-scheme: dark) {
  .token.comment, .token.prolog, .token.doctype, .token.cdata { color: #9ca3af; }
  .token.tag, .token.selector, .token.important, .token.keyword { color: #c4b5fd; }
  .token.attr-name, .token.property, .token.function { color: #7dd3fc; }
  .token.attr-value, .token.string, .token.url, .token.char { color: #86efac; }
  .token.number, .token.boolean, .token.constant, .token.unit { color: #fcd34d; }
  .token.punctuation, .token.operator { color: #d6d3d1; }
  .token.entity, .token.regex, .token.variable { color: #f9a8d4; }
}

/* a new file or folder being named in the list, and a new file not yet saved */
.list li.ghost { grid-template-columns: 1rem 1fr; background: var(--current); }
.ghost-name { width: 100%; font: inherit; padding: .15rem .4rem; border: 1px solid var(--accent); border-radius: 6px;
  background: var(--card); color: var(--fg); outline: none; }
.ghost-name[aria-invalid="true"] { border-color: var(--error); }
.ghost-hint { color: var(--error); margin-top: .2rem; }
.ghost-hint:empty { display: none; }
.list li.draft .name { font-style: italic; }

/* the brain: a chat beside the preview */
button.ask-brain { margin-left: auto; font-family: system-ui, sans-serif; border-color: var(--accent); color: var(--accent); }
button.ask-brain.on { background: var(--accent); color: var(--accent-fg); }
.brain { display: flex; flex-direction: column; min-width: 0; min-height: 0; border-right: 1px solid var(--line); background: var(--card); }
.ai-title { font-size: .9rem; }
#ai-model { min-width: 0; max-width: 13rem; padding: .2rem .4rem; border: 1px solid var(--line); border-radius: 6px; background: var(--card); color: var(--fg); font-size: .82rem; }
.ai-spend { flex: 1; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ai-log { flex: 1; overflow-y: auto; padding: .75rem; display: flex; flex-direction: column; gap: .6rem; }
.ai-msg { max-width: 92%; padding: .5rem .7rem; border-radius: 12px; font-size: .9rem; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.ai-msg.user { align-self: flex-end; background: var(--accent); color: var(--accent-fg); }
.ai-msg.brain { align-self: flex-start; background: var(--bg); border: 1px solid var(--line); }
.ai-msg.streaming .ai-text::after { content: "▍"; color: var(--muted); }
.ai-tools { list-style: none; margin: 0; padding: 0; font: .78rem/1.5 ui-monospace, "Cascadia Code", Menlo, Consolas, monospace; color: var(--muted); }
.ai-tools:empty { display: none; }
.ai-tools li::before { content: "… "; }
.ai-tools li.ok::before { content: "✓ "; color: #15803d; }
.ai-tools li.failed::before { content: "✗ "; color: var(--error); }
.ai-tools + .ai-text:not(:empty) { margin-top: .35rem; }
.ai-meta { margin-top: .35rem; font-size: .72rem; color: var(--muted); white-space: normal; }
.ai-form { display: flex; gap: .5rem; align-items: flex-end; padding: .6rem .75rem; border-top: 1px solid var(--line); }
.ai-form textarea { flex: 1; resize: vertical; min-height: 2.6rem; max-height: 12rem; padding: .45rem .6rem; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--fg); font: inherit; font-size: .9rem; }
.ai-form textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.ai-note { margin: 0; padding: 0 .75rem .5rem; color: var(--muted); }
.ai-note:empty { display: none; }
.ai-note.error { color: var(--error); }

/* ---- The flff look: orderly like a bridge, dense like a parts catalog, a
   little Detroit grit on solid colours (the same tokens as www.flff.fi and the
   sign-in pages). Kept last, so it overrides the neutral defaults above. ---- */
@font-face { font-family: "Antonio"; src: url("fonts/display-700.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Antonio"; src: url("fonts/display-600.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Plex Mono"; src: url("fonts/mono-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Plex Mono"; src: url("fonts/mono-500.woff2") format("woff2"); font-weight: 500; font-display: swap; }
:root {
  --bg: #f6f7f9; --fg: #111827; --muted: #4b5563; --line: #e5e7eb; --card: #ffffff;
  --accent: #b42318; --accent-fg: #ffffff; --hover: #eef0f3; --current: #e8f1f5; --error: #b42318;
  --ops: #e3a52f; --science: #1a6a8a; --hull: #141a22;
  --display: "Antonio", "Arial Narrow", sans-serif; --mono: "Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  --grit: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.72' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1.6 1.15'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)' opacity='.38'/%3E%3C/svg%3E");
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0d1117; --fg: #e6edf3; --muted: #9aa4b1; --line: #262d37; --card: #151b23;
          --accent: #f97066; --accent-fg: #0d1117; --hover: #1a212b; --current: #10283a; --error: #f97066;
          --ops: #f2c14e; --science: #5cbfe0; --hull: #0a0e13; }
}
body { font-size: 14px; }
a { color: var(--science); }
.side::before, .stage::before { content: ""; display: block; flex: none; height: 7px; margin: 4px 4px 0; border-radius: 999px;
  background-image: var(--grit), repeating-linear-gradient(90deg, var(--accent) 0 34%, transparent 34% 34.4%, var(--ops) 34.4% 43%, transparent 43% 43.4%, var(--science) 43.4% 65%, transparent 65% 65.4%, var(--ops) 65.4% 71%, transparent 71% 71.4%, var(--hull) 71.4% 100%); }
.brand { font: 700 1.3rem/1 var(--display); letter-spacing: .05em; text-transform: uppercase; }
h1.title, .signin h1 { font: 700 1.6rem/1.1 var(--display); text-transform: uppercase; letter-spacing: .02em; }
button.primary { border-radius: 999px; background-image: var(--grit); }
button.tool, button.act { border-radius: 6px; font-weight: 500; }
.stat .label { font: 500 .66rem var(--mono); text-transform: uppercase; letter-spacing: .08em; }
.stat .value { font: 700 1.25rem/1.1 var(--display); letter-spacing: .02em; }
.crumbs, .list .meta, .ai-meta, .address, .foot { font-family: var(--mono); }
.list .meta, .ai-meta { font-size: .72rem; }
.card-title { font: 700 1.15rem/1.2 var(--display); text-transform: uppercase; letter-spacing: .03em; color: var(--fg); }
.editor-name, .ai-title, .history-head strong { font-family: var(--mono); font-weight: 500; }
.notice.free { border: 1px solid var(--ops); border-left: 4px solid var(--ops); background: var(--card); color: var(--fg); }
.ai-msg { border-radius: 10px; }
.ai-msg.user { background: var(--hull); color: #e6edf3; }
button.ask-brain { border-radius: 999px; font-weight: 600; }
button.ask-brain.on { background-image: var(--grit); }

/* your own domain (domains.js) */
.domains .domain { border-top: 1px solid var(--line); padding: .6rem 0; }
.domain-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.dbadge { font: 500 .66rem/1 var(--mono, ui-monospace, monospace); text-transform: uppercase; letter-spacing: .05em; padding: .25rem .45rem; border-radius: 999px; background: var(--hover); color: var(--muted); }
.dbadge.verified { background: #e3f1f7; color: #0f5873; } .dbadge.active { background: #e6f4ea; color: #146c2e; }
@media (prefers-color-scheme: dark) { .dbadge.verified { background: #0e2a36; color: #7fd2ee; } .dbadge.active { background: #12301d; color: #7ee2a0; } }
.checklist { list-style: none; padding: 0; margin: .3rem 0; }
.checklist li::before { content: "○ "; color: var(--muted); }
.checklist li.ok::before { content: "✓ "; color: #15803d; }
.methods summary { cursor: pointer; font-size: .85rem; color: var(--science, var(--accent)); margin: .3rem 0; }
.methods h4 { font-size: .82rem; margin: .7rem 0 .2rem; }
table.records { width: 100%; border-collapse: collapse; font-size: .78rem; margin: .2rem 0; }
table.records td { padding: .25rem .3rem; border-top: 1px solid var(--line); vertical-align: top; word-break: break-all; }
table.records .rtype { font-family: var(--mono, ui-monospace, monospace); color: var(--muted); width: 3.2rem; }
table.records code { font-size: .76rem; }
.rnote { display: block; color: var(--muted); font-size: .72rem; word-break: normal; }
.row-actions { display: flex; gap: .4rem; margin-top: .4rem; }
.domain-form { display: flex; gap: .4rem; margin-top: .6rem; }
.domain-input { flex: 1; min-width: 0; padding: .4rem .55rem; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--fg); font: inherit; }

/* the private viewer (files in _u, for the owner only) */
.private-view { flex: 1 1 0; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--card); }
.pv-open #preview { display: none; }
.pv-body { flex: 1; overflow: auto; padding: 1rem; }
.pv-body img { max-width: 100%; height: auto; background: repeating-conic-gradient(var(--hover) 0% 25%, transparent 0% 50%) 50% / 16px 16px; }
.pv-text { margin: 0; font: .8rem/1.5 var(--mono, ui-monospace, monospace); white-space: pre-wrap; overflow-wrap: anywhere; }
a.tool { display: inline-block; text-decoration: none; color: var(--fg); padding: .25rem .65rem; font-size: .82rem; }
.pv-body:has(.pv-pdf) { padding: 0; }
.pv-pdf { width: 100%; height: 100%; border: 0; display: block; background: #525659; }

/* the Admin panel (admin.js): over the whole stage, for platform admins */
.stage { position: relative; }
.admin-view { position: absolute; inset: 0; z-index: 5; display: flex; flex-direction: column; background: var(--bg); }
.admin-view[hidden] { display: none; }
.admin-tabs { display: flex; gap: .25rem; flex: 1; }
.admin-tabs button.current { background: var(--current); border-color: var(--accent); }
.admin-note { margin: 0; padding: .4rem 1rem 0; min-height: 1.2rem; }
.admin-note.error { color: var(--error); }
.admin-note.ok { color: var(--muted); }
.admin-body { flex: 1; overflow: auto; padding: .5rem 1rem 2rem; }
.admin-form, .admin-inline { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: .25rem 0 1rem; }
.admin-inline { margin: .4rem 0 0; flex-basis: 100%; }
.admin-form input, .admin-form select, .admin-inline input, .admin-inline select { padding: .4rem .55rem; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--fg); font: inherit; font-size: .85rem; }
.admin-form input.num { width: 5rem; }
.admin-form .primary { margin: 0; }
.admin-host { display: inline-flex; align-items: center; gap: .2rem; font-size: .85rem; color: var(--muted); }
.admin-table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: 10px; font-size: .88rem; }
.admin-table th { text-align: left; font-weight: 600; font-size: .75rem; color: var(--muted); padding: .45rem .6rem; border-bottom: 1px solid var(--line); }
.admin-table td { padding: .45rem .6rem; border-top: 1px solid var(--line); vertical-align: top; overflow-wrap: anywhere; }
.admin-table tr.disabled td { opacity: .55; }
.admin-table .actions { display: flex; flex-wrap: wrap; gap: .3rem; justify-content: flex-end; }
.admin-table button.armed { border-color: var(--error); color: var(--error); }
.admin-fresh code { font-size: .8rem; overflow-wrap: anywhere; }
.badge { display: inline-block; font-size: .7rem; padding: .05rem .4rem; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.badge.accent { border-color: var(--accent); color: var(--accent); }
.badge.error { border-color: var(--error); color: var(--error); }
.badge.ok { color: var(--fg); }
.admin-table td:first-child a { white-space: nowrap; }
