:root {
  --bg: #f4f6f9; --card: #fff; --text: #111827; --muted: #6b7280; --line: #e5e7eb;
  --brand: #0b5cab; --brand-ink: #fff; --brand-soft: #e8f1fb;
  --open: #b45309; --open-bg: #fef3c7; --working: #1d4ed8; --working-bg: #dbeafe;
  --solved: #047857; --solved-bg: #d1fae5; --danger: #b91c1c;
  --radius: 14px; --shadow: 0 1px 2px rgb(0 0 0 / .06), 0 2px 8px rgb(0 0 0 / .04);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1419; --card: #1a2028; --text: #e5e7eb; --muted: #9ca3af; --line: #2b333d;
    --brand: #4d9de0; --brand-ink: #06121f; --brand-soft: #16283a;
    --open: #fbbf24; --open-bg: #3a2d0d; --working: #93c5fd; --working-bg: #172a46;
    --solved: #6ee7b7; --solved-bg: #0f2e24; --danger: #f87171;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
.wrap { max-width: 720px; margin: 0 auto; padding: 0 16px 40px; }
header.top {
  position: sticky; top: 0; z-index: 5; background: var(--bg);
  padding: calc(env(safe-area-inset-top) + 12px) 0 10px;
  display: flex; align-items: center; gap: 12px;
}
header.top img { width: 36px; height: 36px; border-radius: 9px; }
header.top h1 { font-size: 20px; margin: 0; flex: 1; }
header.top .sub { margin: 0; color: var(--muted); font-size: 13px; font-weight: 400; }
select, input, textarea, button { font: inherit; color: inherit; }
select.lang { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 6px 8px; }

.tabs { display: flex; gap: 6px; background: var(--card); padding: 4px; border-radius: 12px; border: 1px solid var(--line); margin: 6px 0 14px; }
.tabs button { flex: 1; border: 0; background: none; padding: 9px 8px; border-radius: 9px; font-weight: 600; color: var(--muted); cursor: pointer; }
.tabs button[aria-selected="true"] { background: var(--brand); color: var(--brand-ink); }
.count { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 4px; border-radius: 10px; background: var(--open-bg); color: var(--open); font-size: 12px; line-height: 20px; }
.tabs button[aria-selected="true"] .count { background: rgb(255 255 255 / .25); color: inherit; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 12px; }
label { display: block; font-weight: 600; font-size: 14px; margin: 12px 0 5px; }
label:first-child { margin-top: 0; }
input[type=text], input[type=password], textarea {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg);
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
textarea { min-height: 96px; resize: vertical; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 400; margin-top: 14px; }
.check input { width: 20px; height: 20px; }

.btn { border: 0; border-radius: 10px; padding: 11px 16px; font-weight: 600; cursor: pointer; background: var(--brand); color: var(--brand-ink); }
.btn:disabled { opacity: .6; cursor: default; }
.btn.block { width: 100%; margin-top: 16px; padding: 13px; font-size: 17px; }
.btn.ghost { background: var(--brand-soft); color: var(--brand); }
.btn.green { background: var(--solved); color: var(--card); }
.btn.small { padding: 7px 11px; font-size: 14px; }
.btn.danger { background: none; color: var(--danger); }
.link { background: none; border: 0; color: var(--brand); cursor: pointer; padding: 0; font-size: 13px; }

.notice { border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; font-size: 14px; }
.notice.info { background: var(--brand-soft); }
.notice.ok { background: var(--solved-bg); color: var(--solved); font-weight: 600; }
.notice.err { background: #fee2e2; color: #991b1b; }
.notice button { margin-top: 8px; }
.hint { color: var(--muted); font-size: 13px; margin: 6px 0 0; }
.hint button { font-size: 13px; }

.ticket { cursor: pointer; display: block; }
.ticket:hover { border-color: var(--brand); }
.ticket h3 { margin: 6px 0 4px; font-size: 16px; }
.ticket p.body { margin: 0; color: var(--muted); font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.meta { color: var(--muted); font-size: 13px; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
.pill { font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 99px; }
.pill.open { background: var(--open-bg); color: var(--open); }
.pill.working { background: var(--working-bg); color: var(--working); }
.pill.solved { background: var(--solved-bg); color: var(--solved); }
.tag { font-size: 12px; padding: 1px 7px; border-radius: 6px; background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; }
.metoo[aria-pressed="true"] { background: var(--solved-bg); color: var(--solved); }
.empty { text-align: center; color: var(--muted); padding: 30px 0; }

.detail h2 { margin: 10px 0 6px; font-size: 20px; }
.detail .text { white-space: pre-wrap; overflow-wrap: anywhere; }
.thread { margin-top: 16px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 88%; padding: 10px 12px; border-radius: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg .who { font-size: 12px; font-weight: 700; margin-bottom: 2px; opacity: .8; }
.msg.admin { background: var(--brand-soft); align-self: flex-start; border-bottom-left-radius: 4px; }
.msg.user { background: var(--bg); border: 1px solid var(--line); align-self: flex-end; border-bottom-right-radius: 4px; }
.replybox { margin-top: 14px; }
.replybox textarea { min-height: 70px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

.filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.filters button { border: 1px solid var(--line); background: var(--card); border-radius: 99px; padding: 6px 12px; cursor: pointer; font-size: 14px; }
.filters button[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.ticket.unseen { border-left: 4px solid var(--danger); }
.hidden { display: none !important; }
