:root {
  --bg: #f4f5f7; --panel: #ffffff; --side: #15171c; --side-fg: #c9ccd3; --side-on: #ffffff;
  --fg: #1d2026; --muted: #6b7180; --line: #e3e5ea; --accent: #c8102e; --accent-fg: #fff;
  --amber: #b26b00; --amber-bg: #fff3dc; --green: #1f7a3d; --green-bg: #e3f4e8;
  --warn-bg: #fff6f6; --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101216; --panel: #191c22; --side: #0b0c0f; --fg: #e4e6eb; --muted: #8d93a1;
    --line: #2a2e37; --amber: #f0b24a; --amber-bg: #3a2a0d; --green: #6ad08f; --green-bg: #12301d;
    --warn-bg: #2a1719;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--fg); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: inherit; }
h1 { font-size: 24px; margin: 0 0 16px; display: flex; gap: 10px; align-items: center; }
h2 { font-size: 17px; margin: 28px 0 10px; display: flex; gap: 12px; align-items: baseline; }
h3 { font-size: 15px; margin: 20px 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, Consolas, monospace; }
.nowrap { white-space: nowrap; }
.lead { color: var(--muted); max-width: 720px; margin: 0 0 20px; }

.shell { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-fg); padding: 18px 12px; display: flex; flex-direction: column; gap: 18px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; text-decoration: none; color: var(--side-on); padding: 0 8px; }
.brand.big { color: var(--fg); padding: 0; margin-bottom: 8px; font-size: 18px; }
.mark { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 7px; background: var(--accent); color: var(--accent-fg); font-weight: 700; }
nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
nav a { display: flex; justify-content: space-between; align-items: center; padding: 7px 10px; border-radius: 7px; text-decoration: none; }
nav a:hover { background: #ffffff12; color: var(--side-on); }
nav a.on { background: #ffffff1c; color: var(--side-on); }
nav a i { font-style: normal; font-size: 11px; opacity: .5; }
.nav-h { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; opacity: .5; padding: 14px 10px 4px; }
.me { border-top: 1px solid #ffffff1a; padding: 12px 8px 0; display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
.me a { color: var(--side-on); text-decoration: none; font-weight: 500; }
.me form { margin-top: 6px; }
button.link { background: none; border: 0; padding: 0; color: var(--side-fg); cursor: pointer; font: inherit; text-decoration: underline; opacity: .8; }

.main { padding: 28px 32px 60px; min-width: 0; max-width: 1200px; }
.solo { min-height: 100vh; display: grid; place-items: center; padding: 16px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card.flush { padding: 0; overflow-x: auto; }
.card.narrow { max-width: 460px; }
.card.empty { padding: 40px; text-align: center; }
.card + .card, .card + h3 { margin-top: 14px; }
.auth { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 12px; }
.auth form { display: flex; flex-direction: column; gap: 12px; }

label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.auth label { margin: 0; }
input, select, textarea { font: inherit; font-size: 15px; color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 7px; padding: 8px 10px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input:disabled { opacity: .7; }
.hint { font-size: 12px; }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-size: 14px; padding: 8px 14px; border-radius: 7px; border: 1px solid var(--line); background: var(--panel); color: var(--fg); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.btn.danger { color: var(--accent); }

.err { background: var(--warn-bg); color: var(--accent); border-radius: 7px; padding: 8px 12px; font-size: 14px; margin-bottom: 10px; }
.flash { background: var(--green-bg); color: var(--green); border-radius: 7px; padding: 8px 12px; margin-bottom: 16px; }

.head-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; }
.head-row h1 { margin: 0; }
.crumbs { margin: 0 0 6px; font-size: 13px; }
.crumbs a { color: var(--muted); text-decoration: none; }

.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.tbl th, .tbl td { padding: 9px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.off td { opacity: .55; }
.tbl tr.warn td { background: var(--warn-bg); }
.tbl a { text-decoration: none; font-weight: 500; }
.tbl a:hover { text-decoration: underline; }

.pill { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 99px; white-space: nowrap; font-weight: 500; }
.pill.green { background: var(--green-bg); color: var(--green); }
.pill.amber { background: var(--amber-bg); color: var(--amber); }
.pill.gray { background: var(--line); color: var(--muted); }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; text-decoration: none; display: flex; flex-direction: column; gap: 4px; }
.tile:hover { border-color: var(--muted); }

.grid2 { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 16px; align-items: start; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.actions form { margin: 0; }
.invite { border-color: var(--amber); background: var(--amber-bg); margin-bottom: 16px; }
.invite p { margin: 4px 0 10px; }
.copy-row { display: flex; gap: 8px; }
.copy-row input { background: var(--panel); font-size: 13px; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; align-items: center; }
.filters select, .filters input { width: auto; font-size: 14px; padding: 6px 8px; }
.filters input[name=q] { flex: 1; min-width: 180px; }
.pager { display: flex; gap: 16px; padding: 12px 2px; font-size: 14px; }


/* разделы проекта */
:root { --blue: #1d5fbf; --blue-bg: #e4eefc; --red: #b3261e; --red-bg: #fde7e6; }
@media (prefers-color-scheme: dark) { :root { --blue: #7fb0ff; --blue-bg: #14243d; --red: #ff8a80; --red-bg: #3a1614; } }
.pill.blue { background: var(--blue-bg); color: var(--blue); }
.pill.red { background: var(--red-bg); color: var(--red); }
.chip { font-size: 13px; padding: 4px 12px; border-radius: 99px; border: 1px solid var(--line); text-decoration: none; background: var(--panel); }
.chip.on { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.src { font-size: 12px; color: var(--muted); text-decoration: none; margin-left: 4px; }
.src:hover { text-decoration: underline; }
form.inline { display: inline; margin: 0; }
button.x { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 18px; line-height: 1; padding: 0 4px; }
button.x:hover { color: var(--accent); }
button.check { width: 20px; height: 20px; border-radius: 5px; border: 1.5px solid var(--muted); background: var(--panel); color: var(--green); cursor: pointer; font-weight: 700; padding: 0; line-height: 1; }
button.check.on { background: var(--green-bg); border-color: var(--green); }
select.mini, input.mini { font-size: 13px; padding: 3px 6px; width: auto; max-width: 200px; background: transparent; }
.late, .late input { color: var(--red); font-weight: 600; }
.pre { white-space: pre-wrap; word-break: break-word; font-size: 14px; }
details.card summary { cursor: pointer; }
details.card .pre { margin-top: 10px; max-height: 70vh; overflow: auto; }
.thumb { display: block; max-width: 100%; max-height: 220px; border-radius: 6px; margin-top: 6px; }
.file-row { padding: 8px 0; border-bottom: 1px solid var(--line); }
.file-row:last-child { border: 0; }
.file-row audio, .file-row video { width: 100%; margin-top: 6px; }
.upload { margin-bottom: 16px; }
.upload input[type=file] { background: transparent; border-style: dashed; padding: 14px; }
h3.first { margin-top: 0; }
.grid2.even { grid-template-columns: 1fr 1fr; margin-top: 10px; font-size: 14px; }
.head-row.tight { margin-bottom: 4px; align-items: flex-start; }
.actions.top { margin: 0 0 14px; }
.meeting p { margin: 6px 0; }
.card > p:last-child { margin-bottom: 0; }

.side-search input { background: #ffffff12; border-color: #ffffff22; color: var(--side-on); font-size: 14px; padding: 7px 10px; }
.side-search input::placeholder { color: var(--side-fg); opacity: .6; }
.hit { margin-bottom: 10px; }
.hit .pre { margin-top: 6px; max-height: 260px; overflow: auto; }

/* переписки */
.chat { display: flex; flex-direction: column; gap: 6px; max-width: 820px; }
.chat-day { align-self: center; font-size: 12px; color: var(--muted); background: var(--line); border-radius: 99px; padding: 2px 10px; margin: 10px 0 4px; }
.msg { max-width: 78%; padding: 8px 12px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); }
.msg.in { align-self: flex-end; background: var(--blue-bg); border-color: transparent; }
.msg.out { align-self: flex-start; }
.msg.edit { border-style: dashed; }
.msg.button, .msg.button_answer, .msg.command { opacity: .75; font-size: 13px; }
.msg[class*="_failed"] { border-color: var(--red); }
.msg .meta { font-size: 11px; color: var(--muted); margin-top: 4px; text-align: right; }

/* просмотр файлов */
iframe.viewer { width: 100%; height: calc(100vh - 190px); min-height: 520px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.card.center { text-align: center; }
img.full, video.full { max-width: 100%; max-height: 78vh; border-radius: 6px; }
.card audio { width: 100%; }
.fname { word-break: break-word; font-size: 20px; }
.sheet-wrap { overflow: auto; max-height: calc(100vh - 230px); }
table.sheet { border-collapse: collapse; font-size: 13px; }
table.sheet td, table.sheet th { border: 1px solid var(--line); padding: 4px 8px; white-space: nowrap; max-width: 420px; overflow: hidden; text-overflow: ellipsis; vertical-align: top; }
table.sheet th { background: var(--bg); position: sticky; top: 0; font-weight: 600; }
table.sheet td.rn { color: var(--muted); background: var(--bg); text-align: right; position: sticky; left: 0; }
.pad { padding: 8px 14px; }
article.doc { max-width: 880px; line-height: 1.6; }
article.doc h1 { font-size: 22px; } article.doc h2 { font-size: 18px; margin-top: 24px; } article.doc h3 { font-size: 16px; }
article.doc table { border-collapse: collapse; margin: 10px 0; font-size: 14px; }
article.doc td, article.doc th { border: 1px solid var(--line); padding: 5px 9px; vertical-align: top; }
article.doc code, article.doc pre { background: var(--bg); border-radius: 4px; padding: 1px 4px; }
.card.notes { margin-bottom: 14px; }
.doc-row { margin-bottom: 10px; }
.doc-row p { margin: 6px 0; }
.doc-row .chip { padding: 2px 8px; font-size: 12px; }

@media (max-width: 820px) {
  .msg { max-width: 92%; }
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; padding: 12px 16px; gap: 10px; }
  nav { flex-direction: row; flex-wrap: wrap; gap: 4px; }
  nav a i, .nav-h { display: none; }
  .me { flex-direction: row; align-items: center; gap: 10px; padding-top: 8px; }
  .me form { margin: 0 0 0 auto; }
  .main { padding: 20px 16px 48px; }
  .grid2, .grid2.even, .row3 { grid-template-columns: 1fr; }
  .copy-row { flex-direction: column; }
}
