:root {
  --bg: #f6f7f7; --surface: #ffffff; --text: #1b2524; --muted: #5d6b69; --border: #dbe2e1;
  --accent: #0f766e; --accent-text: #ffffff; --user: #d9f0ed; --warn-bg: #fff4d6; --warn-text: #6b4a00;
  --error-bg: #fde8e8; --error-text: #8a1c1c; --bar: #0f766e; --bar-neg: #b42318; --track: #e6ecea;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1514; --surface: #17201f; --text: #e6efed; --muted: #9db0ad; --border: #2a3735;
    --accent: #2dd4bf; --accent-text: #06201d; --user: #16413c; --warn-bg: #3b3210; --warn-text: #f5d97a;
    --error-bg: #3d1717; --error-text: #f5b1b1; --bar: #2dd4bf; --bar-neg: #f97066; --track: #22302e;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
[hidden] { display: none !important; }
button, input, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

/* login */
.login { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 24px; display: grid; gap: 12px; }
.login-card h1 { margin: 0; }
.login-card label { display: grid; gap: 4px; font-size: 14px; color: var(--muted); }
.login-card input { font-size: 16px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); color: var(--text); }

/* app shell: header, scrolling messages, sticky composer */
.app { height: 100%; height: 100dvh; display: flex; flex-direction: column; max-width: 860px; margin: 0 auto; }
.topbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top)); border-bottom: 1px solid var(--border); background: var(--surface); }
.topbar .muted { flex: 1; min-width: 0; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* the account name opens "Ganti kata sandi": text, not a boxed button, underlined so it reads as something to tap */
.topbar .who { flex: 0 1 auto; margin-right: auto; border: 0; background: none; padding: 0; text-align: left; text-decoration: underline dotted; text-underline-offset: 3px; }
.pw-panel { display: grid; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--surface); }
.pw-panel label { display: grid; gap: 4px; font-size: 14px; color: var(--muted); }
.pw-panel input { font-size: 16px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); color: var(--text); }
.pw-panel p { margin: 0; }
.pw-buttons { display: flex; gap: 8px; }
.messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; -webkit-overflow-scrolling: touch; }
.empty { margin: auto; text-align: center; max-width: 30ch; }
.composer { display: flex; gap: 8px; align-items: flex-end; padding: 10px 16px; padding-bottom: max(10px, env(safe-area-inset-bottom)); border-top: 1px solid var(--border); background: var(--surface); }
.composer textarea { flex: 1; resize: none; font-size: 16px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg); max-height: 160px; }

button { border: 1px solid var(--border); background: var(--surface); border-radius: 10px; padding: 8px 12px; cursor: pointer; }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
button.ghost { background: transparent; }
button.small { padding: 4px 10px; font-size: 14px; }
button:disabled { opacity: .55; cursor: default; }
button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* messages */
.msg { display: flex; }
.msg.user { justify-content: flex-end; }
.bubble { max-width: 100%; border-radius: 14px; padding: 10px 14px; overflow-wrap: anywhere; }
.msg.user .bubble { background: var(--user); max-width: 85%; white-space: pre-wrap; }
.msg.assistant .bubble { background: var(--surface); border: 1px solid var(--border); width: 100%; }
.text p { margin: 0 0 8px; } .text p:last-child { margin-bottom: 0; }
.text ul, .text ol { margin: 0 0 8px; padding-left: 22px; }
.text code { background: var(--track); padding: 1px 5px; border-radius: 5px; font-size: 90%; }
.md-h { font-weight: 700; }
.status { color: var(--muted); font-size: 14px; } .status:empty { display: none; }
/* the waiting line: a word with colour moving through it, then plain facts */
.wait-word {
  font-weight: 600;
  background: linear-gradient(90deg, var(--accent) 0%, #d97706 25%, #db2777 50%, #7c3aed 75%, var(--accent) 100%);
  background-size: 300% 100%; -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: wait-shimmer 3s linear infinite;
}
.wait-info { font-variant-numeric: tabular-nums; }
.wait-done { margin-top: 6px; }
@keyframes wait-shimmer { from { background-position: 0% 50%; } to { background-position: 300% 50%; } }
@media (prefers-reduced-motion: reduce) { .wait-word { animation: none; color: var(--accent); background: none; } }
.foot { display: grid; gap: 8px; } .foot:empty { display: none; }
.warn, .error { border-radius: 10px; padding: 8px 12px; font-size: 14px; margin-top: 8px; }
.warn { background: var(--warn-bg); color: var(--warn-text); }
.error { background: var(--error-bg); color: var(--error-text); }
.feedback { display: flex; gap: 8px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.feedback .note { flex: 1; min-width: 12ch; padding: 6px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); }

/* data blocks */
.blocks { display: grid; gap: 10px; } .blocks:not(:empty) { margin-top: 10px; }
.block { border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; background: var(--bg); }
.block-title { font-weight: 600; font-size: 14px; margin-bottom: 8px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; }
.stat-main { border-color: var(--accent); }
.stat-value { font-weight: 700; font-size: 18px; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--muted); font-size: 13px; }
.bar-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "label value" "track track"; gap: 2px 8px; margin-bottom: 8px; }
.bar-label { grid-area: label; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-value { grid-area: value; font-size: 14px; font-variant-numeric: tabular-nums; }
.bar-track { grid-area: track; height: 8px; background: var(--track); border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--bar); border-radius: 4px; } .bar-fill.neg { background: var(--bar-neg); }
.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 0 8px; }
/* a table wider than its box shows a shadow on the side that has more columns, so a cut column reads as "swipe", not
   as broken (the covers scroll with the table and hide the shadow at either end) */
.tablewrap {
  background:
    linear-gradient(to right, var(--bg) 30%, transparent) left / 24px 100% no-repeat local,
    linear-gradient(to left, var(--bg) 30%, transparent) right / 24px 100% no-repeat local,
    radial-gradient(farthest-side at 0 50%, rgba(0,0,0,.18), transparent) left / 10px 100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%, rgba(0,0,0,.18), transparent) right / 10px 100% no-repeat scroll;
}
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td:first-child, th:first-child { white-space: normal; min-width: 12ch; }
th { color: var(--muted); font-weight: 600; } .num { text-align: right; font-variant-numeric: tabular-nums; }
.block-note { color: var(--muted); font-size: 13px; }
.download { display: inline-block; margin-top: 6px; padding: 8px 14px; border-radius: 8px; background: var(--accent); color: var(--accent-text); text-decoration: none; font-weight: 600; }

@media (prefers-reduced-motion: no-preference) { .bar-fill { transition: width .3s ease; } }

/* developer console */
body.konsol { overflow-y: auto; }
.tabs { display: flex; gap: 4px; padding: 8px 16px 0; border-bottom: 1px solid var(--border); background: var(--surface); overflow-x: auto; }
.tab { border: 0; border-bottom: 3px solid transparent; border-radius: 0; background: transparent; padding: 8px 12px; }
.tab.active { border-bottom-color: var(--accent); font-weight: 600; }
.kmain { max-width: 1000px; margin: 0 auto; padding: 16px; display: grid; gap: 12px; }
.linkbtn { text-decoration: none; padding: 8px 12px; border: 1px solid var(--border); border-radius: 10px; color: inherit; font-size: inherit; }
tr.clickable { cursor: pointer; } tr.clickable:hover { background: var(--track); }
.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.filters .note { flex: 0 1 22ch; min-width: 12ch; padding: 6px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); }
.filters .check { display: inline-flex; gap: 6px; align-items: baseline; }
/* the console's long text columns wrap, so its tables fit the page on a desktop (2026-09-30: the conversation list
   was cut after the question, its tools, cost and notes out of sight) */
td.wrap, th.wrap { white-space: normal; min-width: 16ch; overflow-wrap: anywhere; }
.kmain td.num:first-child, .kmain th.num:first-child { min-width: 0; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; margin: 8px 0; } .facts dt { color: var(--muted); } .facts dd { margin: 0; overflow-wrap: anywhere; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; }
pre { background: var(--track); border-radius: 8px; padding: 8px 10px; overflow-x: auto; font-size: 13px; margin: 4px 0 8px; }
.toolname { font-weight: 600; font-size: 14px; }
.cards { display: grid; gap: 10px; margin-top: 10px; }
select { font-size: 16px; padding: 8px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg); color: var(--text); }
.account-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }  /* inputs in line, however long their labels */
.account-form .note, .account-form select { flex: 1 1 14ch; min-width: 12ch; padding: 6px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); color: inherit; }
.password-once { padding: 10px 12px; border-radius: 10px; background: var(--warn-bg); color: var(--warn-text); font-weight: 600; display: grid; gap: 6px; }
.password-once .secret { font: 700 22px/1.3 ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; letter-spacing: 1px; white-space: nowrap; user-select: all; }
.account-form .field { display: flex; flex-direction: column; gap: 3px; flex: 1 1 18ch; min-width: 14ch; }
.account-form .field[hidden] { display: none; }
.account-form .field .note, .account-form .field select { flex: none; width: 100%; box-sizing: border-box; }

/* touch screens: controls big enough for a finger (about 44px) */
@media (pointer: coarse) {
  button, .linkbtn, .download { min-height: 44px; }
  button.small { min-height: 40px; padding: 8px 12px; }
  .linkbtn { display: inline-flex; align-items: center; }
}
/* a grid or flex item is as wide as its widest content unless told otherwise: a table that does not wrap (nowrap
   cells) then stretched the answer's blocks and the console's page past a phone's screen instead of scrolling in its
   own box (screenshots at 360px, 2026-09-30) */
.blocks, .kmain, .cards { grid-template-columns: minmax(0, 1fr); }
.block, .bubble, .kmain > *, .cards > * { min-width: 0; }
.narrow-only { display: none; }
@media (max-width: 480px) { .narrow-only { display: inline; } }
/* narrow phones: the top bar stays on one line, with shorter labels and without the account name */
@media (max-width: 480px) {
  .topbar { padding-left: 12px; padding-right: 12px; }
  .topbar { column-gap: 6px; }
  .topbar button, .topbar .linkbtn { padding: 6px 8px; font-size: 14px; }
  /* the account's login stays beside the title, its role only when it fits (fitWho in app.js) (2026-09-30: it was
     hidden; on a line of its own it was not liked) */
  .wide-only { display: none; }
  .tabs { gap: 0; padding-left: 8px; padding-right: 8px; }
  .tab { padding: 8px 7px; font-size: 15px; }
  /* larger text (Android's font size, zoom): the tabs take two lines rather than hide one, and a bar's label wraps
     rather than being cut (screenshots at 130%, 2026-09-30: the Akun tab out of sight, "Belum ja…") */
  .tabs { flex-wrap: wrap; overflow-x: visible; }
  .bar-label { white-space: normal; overflow: visible; }
  .messages, .kmain { padding: 12px; }
  th, td { padding: 6px 6px; }
  .kmain td:first-child, .kmain th:first-child { min-width: 10ch; }
}
