:root {
  color-scheme: light dark;
  --bg: #ffffff; --s1: #f4f3ee; --tx: #1f1e1c; --tx2: #5f5e5a; --tx3: #8a8983;
  --bd: rgba(0, 0, 0, .12); --bd2: rgba(0, 0, 0, .28);
  --ac: #0F6E56; --ac-bg: #e1f5ee; --ac-tx: #085041;
  --ok: #3b6d11; --ok-bg: #eaf3de; --ok-tx: #27500a;
  --warn-bg: #faeeda; --warn-tx: #633806; --bad: #a32d2d; --on: #ffffff;
  --radius: 8px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #1c1c1a; --s1: #2a2a27; --tx: #f1efe8; --tx2: #b4b2a9; --tx3: #888780;
    --bd: rgba(255, 255, 255, .14); --bd2: rgba(255, 255, 255, .3);
    --ac: #1D9E75; --ac-bg: #085041; --ac-tx: #9fe1cb;
    --ok: #639922; --ok-bg: #27500a; --ok-tx: #c0dd97;
    --warn-bg: #633806; --warn-tx: #faeeda; --bad: #f09595;
  }
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1c1c1a; --s1: #2a2a27; --tx: #f1efe8; --tx2: #b4b2a9; --tx3: #888780;
  --bd: rgba(255, 255, 255, .14); --bd2: rgba(255, 255, 255, .3);
  --ac: #1D9E75; --ac-bg: #085041; --ac-tx: #9fe1cb;
  --ok: #639922; --ok-bg: #27500a; --ok-tx: #c0dd97;
  --warn-bg: #633806; --warn-tx: #faeeda; --bad: #f09595;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--tx); }
body { font: 400 16px/1.5 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--ac); }
i.ti { vertical-align: -2px; }

#app { max-width: 560px; margin: 0 auto; min-height: 100vh; }
#view { padding: calc(env(safe-area-inset-top) + 16px) 18px calc(96px + env(safe-area-inset-bottom)); }
#view.bare { padding-bottom: calc(40px + env(safe-area-inset-bottom)); }
#nav {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex; max-width: 560px; margin: 0 auto;
  background: var(--bg); border-top: 0.5px solid var(--bd); padding-bottom: env(safe-area-inset-bottom);
}
#nav:empty { display: none; }
.tab {
  flex: 1; border: 0; background: transparent; padding: 10px 0 12px; display: flex; flex-direction: column;
  align-items: center; gap: 2px; font-size: 11px; color: var(--tx3); cursor: pointer; text-decoration: none;
}
.tab i { font-size: 22px; }
.tab.on { color: var(--ac); }

#composer {
  display: none; position: fixed; left: 0; right: 0; bottom: 0; max-width: 560px; margin: 0 auto; z-index: 5;
  background: var(--bg); border-top: 0.5px solid var(--bd); padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
}
#composer.show { display: block; }
#app:has(#composer.show) #view { padding-bottom: calc(110px + env(safe-area-inset-bottom)); }
.comp { display: flex; gap: 8px; align-items: center; }
.comp input { flex: 1; min-width: 0; height: 44px; border-radius: 22px; padding: 0 16px; border: 0.5px solid var(--bd2); background: transparent; font-size: 16px; }
.rbtn {
  width: 44px; height: 44px; border-radius: 50%; border: 0.5px solid var(--bd2); background: transparent; flex: none;
  cursor: pointer; display: flex; align-items: center; justify-content: center; color: var(--tx); padding: 0;
}
.rbtn.pri { background: var(--ac); border-color: var(--ac); color: var(--on); }
.rbtn.on { background: var(--bad); border-color: var(--bad); color: var(--on); }
.comphint { margin: 4px 0 0 6px; font-size: 12px; color: var(--tx3); }

.head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 14px; gap: 10px; }
.title { font-size: 22px; font-weight: 500; line-height: 1.2; }
.sub { font-size: 13px; color: var(--tx2); margin-top: 2px; }
.lbl { font-size: 12px; color: var(--tx2); margin-top: 14px; }
.hint { font-size: 13px; color: var(--tx2); margin: 6px 0 0; }
.group { font-size: 12px; color: var(--tx2); margin-top: 18px; }
.note { background: var(--warn-bg); color: var(--warn-tx); border-radius: 10px; padding: 10px 12px; font-size: 13px; margin: 10px 0; }
.note a, .note .link { color: inherit; font-weight: 500; }

.icon-btn {
  width: 40px; height: 40px; border: 0.5px solid var(--bd2); background: transparent; border-radius: 10px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; color: var(--tx); flex: none; padding: 0;
}

.hbtns { display: flex; gap: 8px; }
.card { background: var(--s1); border-radius: 12px; padding: 12px 14px; margin-bottom: 14px; }
.card .top { font-size: 13px; color: var(--tx2); margin-bottom: 4px; }
.card .v2 { font-size: 17px; }
.card.cont { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--ac-bg); color: var(--ac-tx); }
.card.cont .k { font-size: 12px; opacity: .85; }
.card.cont .v { font-size: 16px; font-weight: 500; }
.bar { height: 6px; border-radius: 3px; background: var(--bd); overflow: hidden; margin-top: 4px; }
.bar > div { height: 100%; background: var(--ac); }
.metrics { display: flex; gap: 10px; margin-bottom: 12px; }
.metric { flex: 1; background: var(--s1); border-radius: 12px; padding: 10px 14px; }
.metric .k { font-size: 12px; color: var(--tx2); }
.metric .v { font-size: 20px; font-weight: 500; }

.tm {
  width: 100%; display: flex; align-items: center; gap: 14px; text-align: left; cursor: pointer;
  border: 0.5px solid var(--bd2); background: transparent; border-radius: 12px; padding: 14px 16px; margin-bottom: 10px;
}
.tm b { font-size: 22px; font-weight: 500; min-width: 74px; }
.tm span { font-size: 14px; color: var(--tx2); line-height: 1.35; }
.tm:active { background: var(--s1); }

.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.chip { border: 0.5px solid var(--bd2); background: transparent; border-radius: 999px; padding: 7px 12px; font-size: 14px; color: var(--tx2); cursor: pointer; }
.chip.on { background: var(--ac-bg); color: var(--ac-tx); border-color: var(--ac); }
.chips.fill .chip { flex: 1; text-align: center; }

.row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 0.5px solid var(--bd); cursor: pointer; }
.row.plain { cursor: default; }
.row .main { flex: 1; min-width: 0; }
.row .name { font-size: 15px; }
.row .meta { font-size: 12px; color: var(--tx3); }
.row > .meta { text-align: right; flex: none; max-width: 45%; }
.sic { width: 36px; height: 36px; border-radius: 10px; background: var(--ac-bg); color: var(--ac-tx); display: flex; align-items: center; justify-content: center; flex: none; }
.badge { font-size: 11px; background: var(--s1); color: var(--tx2); border-radius: 6px; padding: 2px 6px; margin-left: 6px; white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok-tx); }
.kv { background: var(--s1); border-radius: 12px; padding: 4px 14px; margin-top: 10px; }
.kv div { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; font-size: 14px; }
.kv div + div { border-top: 0.5px solid var(--bd); }
.kv span:first-child { color: var(--tx2); }

button.btn {
  height: 42px; padding: 0 16px; border: 0.5px solid var(--bd2); background: transparent; border-radius: var(--radius);
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; color: var(--tx);
}
button.btn.block { width: 100%; margin-top: 10px; }
button.btn.primary { background: var(--ac); border-color: var(--ac); color: var(--on); }
button.btn.danger { color: var(--bad); }
button.btn:disabled { opacity: .5; cursor: default; }
button.link { border: 0; background: transparent; color: var(--ac); cursor: pointer; padding: 6px 4px; font-size: 14px; }
button.link.mute { color: var(--tx2); font-size: 13px; }

input[type=text], input[type=password], select, textarea {
  width: 100%; height: 42px; padding: 0 10px; border: 0.5px solid var(--bd2); border-radius: var(--radius);
  background: transparent; font-size: 16px;
}
textarea { height: auto; min-height: 76px; padding: 8px 10px; }
input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--ac); }
label.l { display: block; font-size: 13px; color: var(--tx2); margin: 14px 0 6px; }
label.tog { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; font-size: 15px; cursor: pointer; }

.backbar { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.backbar button { border: 0; background: transparent; width: 32px; height: 32px; padding: 0; cursor: pointer; color: var(--tx); display: flex; align-items: center; justify-content: center; }
.backbar span { font-size: 13px; color: var(--tx2); }
.backbar.big span { font-size: 18px; font-weight: 500; color: var(--tx); }

.empty { text-align: center; padding: 36px 12px; }
.empty i { font-size: 36px; color: var(--tx3); }
.empty h3 { font-size: 17px; font-weight: 500; margin: 10px 0 4px; }
.empty p { font-size: 14px; color: var(--tx2); margin: 0 0 14px; }

#toast {
  position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--tx); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px;
  max-width: 90%; display: none; z-index: 10;
}
#toast.show { display: block; }

.stop { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.stt { flex: 1; min-width: 0; }
.stt .t { font-size: 16px; font-weight: 500; line-height: 1.25; }
.stt .s { font-size: 12px; color: var(--tx2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.clk { font-size: 15px; font-variant-numeric: tabular-nums; color: var(--tx2); }
.clk.over { color: var(--bad); }
.prog { margin-bottom: 14px; }

.fc { background: var(--s1); border-radius: 16px; padding: 28px 18px 18px; text-align: center; margin-bottom: 14px; }
.fc .en { font-size: 32px; font-weight: 500; line-height: 1.2; margin: 6px 0 2px; overflow-wrap: anywhere; }
.fc .ex { font-size: 16px; margin: 12px 0 0; }
.fc .rev { border-top: 0.5px solid var(--bd); margin-top: 16px; padding-top: 14px; }
.fc .pt1 { font-size: 20px; font-weight: 500; }
.rate { display: flex; gap: 8px; }
.rate button {
  flex: 1; border: 0.5px solid var(--bd2); background: transparent; border-radius: 10px; padding: 10px 0 8px;
  font-size: 14px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.rate small { font-size: 11px; color: var(--tx3); }

.chat { display: flex; flex-direction: column; }
.msg { display: flex; flex-direction: column; margin-bottom: 14px; }
.bubble { max-width: 88%; padding: 10px 14px; border-radius: 16px; line-height: 1.45; overflow-wrap: anywhere; }
.msg.ai .bubble { background: var(--s1); align-self: flex-start; border-bottom-left-radius: 4px; }
.msg.me .bubble { background: var(--ac-bg); color: var(--ac-tx); align-self: flex-end; border-bottom-right-radius: 4px; }
.tools { display: flex; gap: 2px; margin-top: 2px; }
.tools button { border: 0; background: transparent; color: var(--tx2); font-size: 13px; padding: 6px 8px 6px 4px; cursor: pointer; }
.pt { font-size: 14px; color: var(--tx2); margin: 0 0 0 4px; max-width: 88%; }
.fix { align-self: flex-end; max-width: 92%; margin-top: 6px; background: var(--ok-bg); color: var(--ok-tx); border-radius: 12px; padding: 10px 12px; font-size: 14px; }
.fix .k { font-size: 12px; opacity: .85; }
.fix .pt2 { font-size: 13px; opacity: .9; }
.fix button.link { color: inherit; padding: 0 2px; }
.sugs { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.sug {
  text-align: left; border: 0.5px solid var(--bd2); background: transparent; border-radius: 12px; padding: 10px 14px; cursor: pointer;
  display: flex; flex-direction: column;
}
.sug small { font-size: 12px; color: var(--tx2); }
.errbox { background: var(--s1); border-radius: 12px; padding: 12px 14px; font-size: 14px; color: var(--bad); display: flex; flex-direction: column; gap: 10px; align-items: flex-start; margin-bottom: 14px; }
.errbox .btn { color: var(--tx); }
.typing { display: inline-flex; gap: 5px; align-items: center; height: 40px; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--tx3); animation: blink 1.2s infinite ease-in-out; }
.typing span:nth-child(2) { animation-delay: .2s; } .typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

.done { text-align: center; padding: 10px 0 16px; }
.done i { font-size: 40px; color: var(--ok); }
.done .title { margin-top: 4px; }

.bars { display: flex; gap: 6px; align-items: flex-end; margin-top: 8px; }
.bcol { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; }
.bw { width: 100%; height: 84px; display: flex; align-items: flex-end; }
.bv { width: 100%; background: var(--ac); border-radius: 5px 5px 0 0; min-height: 2px; opacity: .85; }
.bl { font-size: 11px; color: var(--tx3); }
.bm { font-size: 11px; color: var(--tx2); min-height: 14px; }
.log { background: var(--s1); border-radius: 10px; padding: 8px 12px; font-size: 12px; color: var(--tx2); margin-top: 6px; }
