:root {
  --bg: #0d1117;
  --panel: #11161d;
  --raised: #161c25;
  --hover: #1c2430;
  --border: #232c38;
  --text: #d6dde6;
  --dim: #8592a3;
  --accent: #4f9dff;
  --accent-strong: #2f7fe6;
  --ok: #3fb950;
  --warn: #d29922;
  --danger: #f85149;
  --radius: 10px;
  --sans: "Segoe UI", "Inter", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); font: 15px/1.45 var(--sans); overflow-x: clip; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }

input, select, textarea {
  width: 100%;
  background: var(--raised);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; }

.btn {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 14px;
  background: var(--raised);
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, transform .1s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .55; cursor: default; }
.btn--primary { background: var(--accent-strong); color: #fff; }
.btn--primary:hover { background: var(--accent); }
.btn--ghost { border-color: var(--border); background: transparent; }
.btn--danger { background: #3b1518; color: #ffb3ae; border-color: #5c2226; }
.btn--small { padding: 5px 10px; font-size: 13px; }
.grow { flex: 1; }

.muted { color: var(--dim); }
.small { font-size: 13px; }
.center { text-align: center; }
.error { color: var(--danger); }

.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login__card { width: 100%; max-width: 360px; background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 28px 22px; }
.login__card form { display: grid; gap: 12px; margin-top: 16px; }
.brand { font-size: 22px; font-weight: 700; letter-spacing: .04em; display: flex; align-items: center; gap: 10px; }
.brand__mark { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: linear-gradient(135deg, #4f9dff, #7a5cff); color: #fff; }

.main { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  background: rgba(13, 17, 23, .92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar__title { flex: 1; font-weight: 600; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn { background: none; border: 0; font-size: 28px; line-height: 1; padding: 0 8px 2px 0; cursor: pointer; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); box-shadow: 0 0 0 3px rgba(248, 81, 73, .15); }
.dot.is-on { background: var(--ok); box-shadow: 0 0 0 3px rgba(63, 185, 80, .15); }

.view { padding: 12px 14px calc(16px + env(safe-area-inset-bottom)); flex: 1; }
.toolbar { display: flex; gap: 8px; margin-bottom: 12px; }
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.client {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px;
  padding: 12px 14px; border-radius: var(--radius);
  background: var(--panel); border: 1px solid var(--border); cursor: pointer;
}
.client:active { background: var(--hover); }
.client__name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.client__meta { grid-column: 1 / -1; color: var(--dim); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: #1b2a40; color: #9cc6ff; align-self: start; }
.pill--work { background: #13301c; color: #8ee29d; }
.pill--done { background: #262c35; color: var(--dim); }
.pill--lost { background: #3b1518; color: #ffb3ae; }

.tabs { display: flex; gap: 4px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 4px; margin-bottom: 12px; }
.tab { flex: 1; border: 0; background: transparent; padding: 8px; border-radius: 7px; cursor: pointer; color: var(--dim); }
.tab.is-active { background: var(--raised); color: var(--text); }
.badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent-strong); color: #fff; font-size: 12px; }

.pane { display: grid; gap: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.file-btn { display: inline-flex; align-items: center; }
.check { display: flex; align-items: center; gap: 6px; color: var(--dim); }
.check input { width: auto; }

.verdict { padding: 12px 14px; border-radius: var(--radius); background: #1d1a0f; border: 1px solid #4a3b12; }
.verdict b { color: var(--warn); display: block; margin-bottom: 4px; font-size: 13px; }
.draft { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; display: grid; gap: 8px; }
.draft__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.draft__label { font-weight: 600; }
.draft__len { color: var(--dim); font-size: 12px; }
.draft__len.is-over { color: var(--danger); }
.draft__text { white-space: pre-wrap; word-break: break-word; user-select: text; }
.draft .btn.is-done { background: #13301c; color: #8ee29d; }

.notice { padding: 10px 12px; border-radius: var(--radius); background: #1d1a0f; border: 1px solid #4a3b12; font-size: 14px; }
.preview-btn { display: block; margin-top: 8px; }
.preview-img { display: block; width: 100%; margin-top: 10px; border-radius: 8px; border: 1px solid var(--border); }
.notice ul { margin: 6px 0 0; padding-left: 18px; }
.queue { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; }
.queue__head { display: flex; align-items: center; gap: 8px; }
.queue__head .btn { margin-left: auto; }
.queue ol { margin: 8px 0 0; padding-left: 20px; display: grid; gap: 6px; }
.queue li { font-size: 14px; }
.queue__item { display: flex; gap: 6px; align-items: flex-start; }
.queue__text { flex: 1; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; word-break: break-word; }

.dialog { display: grid; gap: 8px; }
.bubble { padding: 10px 12px; border-radius: 12px; white-space: pre-wrap; word-break: break-word; font-size: 14px; user-select: text; max-width: 100%; }
.bubble--operator { background: #13284a; border: 1px solid #1f3d6b; justify-self: end; max-width: 88%; }
.bubble--architect { background: var(--panel); border: 1px solid var(--border); }
.bubble__time { display: block; color: var(--dim); font-size: 11px; margin-top: 4px; }
.steps { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 12px; display: grid; gap: 4px; font-size: 13px; max-height: 40vh; overflow: auto; }
.step { display: flex; gap: 8px; }
.step__mark { width: 16px; flex: none; color: var(--dim); }
.step.is-ok .step__mark { color: var(--ok); }
.step__title { flex: 1; word-break: break-word; }
.steps__live { color: var(--accent); font-weight: 600; }
.composer { position: sticky; bottom: 0; background: var(--bg); padding: 8px 0 calc(4px + env(safe-area-inset-bottom)); display: grid; gap: 8px; border-top: 1px solid var(--border); }

.files { display: grid; gap: 8px; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }
.drop { border: 1px dashed var(--border); border-radius: var(--radius); padding: 14px; text-align: center; color: var(--dim); font-size: 13px; }
.drop.is-over { border-color: var(--accent); color: var(--text); background: #12213a; }
.file { display: flex; gap: 8px; align-items: center; padding: 10px 12px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); }
.file__name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file__meta { color: var(--dim); font-size: 12px; white-space: nowrap; }

.form { display: grid; gap: 10px; }
.form label { display: grid; gap: 4px; color: var(--dim); font-size: 13px; }
.form h3 { margin: 0 0 4px; }

.sheet { width: min(420px, 94vw); border: 1px solid var(--border); border-radius: 16px; background: var(--panel); color: var(--text); padding: 18px; }
.sheet::backdrop { background: rgba(0, 0, 0, .6); }

.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: #222b38; border: 1px solid var(--border); padding: 10px 16px; border-radius: 12px; z-index: 20;
  max-width: 92vw; font-size: 14px; box-shadow: 0 8px 24px rgba(0, 0, 0, .4);
}
.toast.is-error { background: #3b1518; border-color: #5c2226; }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid rgba(255, 255, 255, .35); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -2px; margin-right: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (min-width: 900px) {
  .view { max-width: 820px; margin: 0 auto; width: 100%; }
}
.self { background: #0f1a14; border-color: #1f4a33; display: grid; gap: 6px; }
.self p { margin: 0; }
.self ul { margin: 0; }
.self .btn { justify-self: start; }
.hint { margin: 6px 2px 0; line-height: 1.35; }
.teach { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: end; margin-top: 12px; }
.teach textarea { min-height: 0; }
.lessons { display: grid; gap: 8px; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }
.lessons p { margin: 0; }
.lesson { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 8px; padding: 10px 12px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); font-size: 14px; }
.lesson__text { overflow-wrap: anywhere; }
.lesson__kind--rule { background: #3b1518; color: #ffb3ae; }
.lesson__kind--taste { background: #13301c; color: #8ee29d; }
.lesson__actions { grid-column: 1 / -1; display: flex; gap: 6px; justify-content: flex-end; }
