@font-face { font-family: Vazirmatn; src: url("/vazirmatn.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }

:root {
  --bg: #f4f5f7; --card: #fff; --text: #1b1d21; --muted: #6b7280; --line: #e4e6ea;
  --accent: #1e3a8a; --on-accent: #fff; --on: #15803d; --off: #b91c1c; --soft: #eef1f6;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111317; --card: #1a1d22; --text: #e8eaed; --muted: #9aa0a8; --line: #2a2e35;
    --accent: #7c9cf0; --on-accent: #0b1020; --on: #4ade80; --off: #f87171; --soft: #22262d;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.6 Vazirmatn, Tahoma, sans-serif; }
[hidden] { display: none !important; }
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 17px; margin: 0; }
h3 { font-size: 15px; margin: 0 0 4px; color: var(--muted); font-weight: 500; }
button { font: inherit; cursor: pointer; border: 0; border-radius: 8px; padding: 8px 16px; background: var(--accent); color: var(--on-accent); }
button:disabled { opacity: .5; cursor: default; }
button.link { background: none; color: var(--accent); padding: 6px 8px; }
button.ghost { background: none; color: var(--text); border: 1px solid var(--line); }
button.danger { background: none; color: var(--off); border: 1px solid var(--line); }
input, textarea { font: inherit; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--text); }
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.ltr { direction: ltr; text-align: center; }

/* sign in */
#login { max-width: 340px; margin: 12vh auto 0; padding: 0 16px; }
.box { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 24px; display: grid; gap: 16px; }
.box input { width: 100%; margin-top: 6px; direction: ltr; text-align: center; }
.msg { text-align: center; color: var(--off); min-height: 1.6em; }

/* layout */
#panel { display: flex; min-height: 100vh; }
#side { width: 230px; flex: none; background: var(--card); border-inline-end: 1px solid var(--line); padding: 16px 10px; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { font-weight: 700; font-size: 17px; padding: 0 10px 12px; }
#nav { flex: 1; }
.group { color: var(--muted); font-size: 13px; padding: 14px 10px 4px; }
.item { display: block; width: 100%; text-align: start; background: none; color: var(--text); padding: 7px 10px; border-radius: 8px; }
.item:hover { background: var(--soft); }
.item[aria-current="page"] { background: var(--soft); color: var(--accent); font-weight: 600; }
.out { align-self: flex-start; margin-top: 8px; }
.page { flex: 1; min-width: 0; padding: 16px 20px 40px; }
.page > header { display: flex; align-items: center; gap: 4px; margin-bottom: 16px; }
.page > header h1 { flex: 1; }
#view { max-width: 760px; }
.menu { display: none; font-size: 20px; line-height: 1; }
.shade { display: none; }

@media (max-width: 760px) {
  #side { position: fixed; inset-block: 0; right: 0; z-index: 10; transform: translateX(100%); transition: transform .2s; box-shadow: none; }
  #panel.open #side { transform: none; box-shadow: 0 0 24px rgba(0, 0, 0, .25); }
  #panel.open .shade { display: block; position: fixed; inset: 0; z-index: 9; background: rgba(0, 0, 0, .35); }
  .menu { display: block; }
  .page { padding: 12px 16px 40px; }
}

/* cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 16px; }
.top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.top h2 { flex: 1; }
.state { font-size: 14px; color: var(--muted); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-inline-end: 6px; background: var(--off); }
.dot.on { background: var(--on); }
.nums { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.num { background: var(--soft); border-radius: 8px; padding: 10px; }
.num b { display: block; font-size: 18px; }
.num span { color: var(--muted); font-size: 13px; }
@media (max-width: 520px) { .nums { grid-template-columns: repeat(2, 1fr); } }
.error { color: var(--off); font-size: 14px; margin: 10px 0 0; }
.note { color: var(--muted); font-size: 13px; margin: 0; }
.empty { color: var(--muted); }

/* rows: a switch, a number, a field */
.rows { list-style: none; margin: 0; padding: 0; }
.rows > li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.rows > li:last-child { border-bottom: 0; }
.rows .label { flex: 1; min-width: 180px; }
.rows .label small { display: block; color: var(--muted); font-size: 12px; }
.edit { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.edit input.ltr { width: 140px; }
input[type="checkbox"] { width: 16px; height: 16px; padding: 0; margin: 0; accent-color: var(--accent); }
.edit .unit { color: var(--muted); font-size: 13px; }
.check { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--muted); }

.switch { position: relative; flex: none; width: 42px; height: 24px; border-radius: 12px; padding: 0; background: var(--line); }
.switch::after { content: ""; position: absolute; top: 3px; right: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: right .15s; }
.switch[aria-checked="true"] { background: var(--on); }
.switch[aria-checked="true"]::after { right: 21px; }

/* texts */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.chip { background: var(--card); color: var(--text); border: 1px solid var(--line); padding: 5px 12px; font-size: 14px; }
.chip[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.text { border-bottom: 1px solid var(--line); }
.text:last-child { border-bottom: 0; }
.text summary { cursor: pointer; padding: 10px 0; display: flex; align-items: center; gap: 8px; }
.text summary::-webkit-details-marker { display: none; }
.text summary::before { content: "◂"; color: var(--muted); font-size: 12px; }
.text[open] summary::before { content: "▾"; }
.badge { font-size: 12px; color: var(--accent); background: var(--soft); border-radius: 6px; padding: 0 6px; }
.text textarea { width: 100%; min-height: 160px; resize: vertical; line-height: 1.7; }
.vars { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.var { background: var(--soft); color: var(--text); font-size: 12px; padding: 3px 8px; border-radius: 6px; direction: ltr; }
.actions { display: flex; gap: 8px; padding: 4px 0 14px; flex-wrap: wrap; align-items: center; }
.problem { color: var(--off); font-size: 13px; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 8px 16px; border-radius: 8px; font-size: 14px; max-width: calc(100% - 32px); z-index: 20; }

/* tickets: the list beside the conversation; on a phone one at a time */
.chat { display: grid; grid-template-columns: 280px 1fr; gap: 12px; height: calc(100vh - 90px); min-height: 420px; }
.tlist, .thread { background: var(--card); border: 1px solid var(--line); border-radius: 12px; min-height: 0; }
.tlist { overflow-y: auto; padding: 10px; }
.tabs { margin-bottom: 8px; }
.trow { display: grid; gap: 2px; width: 100%; text-align: start; background: none; color: var(--text); padding: 9px 10px; border-radius: 8px; border-bottom: 1px solid var(--line); }
.trow:hover, .trow[aria-current="true"] { background: var(--soft); }
.tname { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; min-width: 0; }
.tname b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tat, .tid { color: var(--muted); font-size: 12px; white-space: nowrap; }
.tlast { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread { display: flex; flex-direction: column; overflow: hidden; }
.thead { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.thead .tname { flex: 1; flex-direction: column; align-items: flex-start; gap: 0; min-width: 0; }
.thead .tat { white-space: normal; }
.thead .danger { flex: none; }
.back { display: none; }
.msgs { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.bubble { max-width: 80%; align-self: flex-start; background: var(--soft); border-radius: 12px; padding: 8px 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble.mine { align-self: flex-end; background: var(--accent); color: var(--on-accent); }
.bubble time { display: block; font-size: 11px; opacity: .7; margin-top: 2px; }
.composer { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); align-items: flex-end; }
.composer textarea { flex: 1; resize: none; min-height: 44px; max-height: 160px; }
.pick { margin: auto; }
.page:has(.chat) #view, .page:has(.bridge) #view { max-width: none; }

@media (max-width: 760px) {
  .chat { grid-template-columns: 1fr; height: calc(100vh - 76px); }
  .chat .thread { display: none; }
  .chat.reading .tlist { display: none; }
  .chat.reading .thread { display: flex; }
  .back { display: block; }
}

/* scrollbars: thin, in the page's colours, no arrows */
* { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: var(--muted); }
::-webkit-scrollbar-button { display: none; width: 0; height: 0; }
::-webkit-scrollbar-corner { background: transparent; }

.hint { margin: 0; color: var(--muted); }
a.button { display: block; text-align: center; text-decoration: none; background: var(--accent); color: var(--on-accent); border-radius: 8px; padding: 9px 16px; }

/* files in a conversation */
.file img, .file video { display: block; max-width: 100%; max-height: 320px; border-radius: 8px; cursor: zoom-in; margin-bottom: 4px; }
.file audio { max-width: 100%; }
.file a { color: inherit; }
.file .ghost { font-size: 13px; padding: 4px 10px; margin-bottom: 4px; }
.bubble.mine .file .ghost { color: var(--on-accent); border-color: currentColor; }

/* SoulTunnel's bot in the panel */
.bridge { display: flex; flex-direction: column; height: calc(100vh - 90px); min-height: 420px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.bubble.bot { max-width: 92%; white-space: normal; }
.btext { white-space: pre-wrap; }
.btext blockquote { margin: 6px 0; padding: 2px 10px; border-inline-start: 3px solid var(--accent); }
.btext code, .btext pre { font-family: ui-monospace, Consolas, monospace; font-size: 13px; direction: ltr; unicode-bidi: isolate; }
.btext pre { white-space: pre-wrap; background: var(--bg); padding: 6px 8px; border-radius: 6px; }
.btext a { color: var(--accent); }
.spoiler { background: var(--muted); color: transparent; border-radius: 4px; cursor: pointer; }
.spoiler:hover { color: inherit; background: none; }
.ikb { display: grid; gap: 4px; margin-top: 8px; }
.krow { display: flex; gap: 4px; }
.kbtn { flex: 1; min-width: 0; background: var(--card); color: var(--text); border: 1px solid var(--line); padding: 7px 8px; font-size: 14px; overflow: hidden; text-overflow: ellipsis; }
.kbtn:hover { background: var(--bg); }
.kbd { display: grid; gap: 4px; padding: 8px 10px 0; border-top: 1px solid var(--line); max-height: 40vh; overflow-y: auto; }
.quick { display: flex; gap: 6px; flex-wrap: wrap; padding-bottom: 4px; }
.quick .chip { font-size: 13px; padding: 4px 10px; }
.bridge .composer { border-top: 0; }
.typing { align-self: flex-start; }

/* small daily chart */
.bars { display: flex; gap: 4px; align-items: flex-end; height: 120px; margin: 14px 0 6px; }
.bar { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; gap: 2px; min-width: 0; }
.bar i { display: block; width: 100%; background: var(--accent); border-radius: 4px 4px 0 0; }
.bar span { font-size: 10px; color: var(--muted); white-space: nowrap; overflow: hidden; max-width: 100%; }
.search input { flex: 1; min-width: 0; }
.search { width: 100%; }

@media (max-width: 760px) {
  .bridge { height: calc(100vh - 76px); }
}
.nums.four { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 520px) { .nums.four { grid-template-columns: repeat(2, 1fr); } }
.bar { max-width: 44px; }
.bars { justify-content: flex-start; }
