:root {
  color-scheme: dark;
  --bg: #101623;
  --surface: #182233;
  --surface-raised: #1f2b3f;
  --line: #2c3b54;
  --text: #f3f7ff;
  --muted: #a6b6ce;
  --accent: #8dbdff;
  --accent-strong: #b7d4ff;
  --on-accent: #10213c;
  --mint: #80e6bd;
  --gold: #ffd38c;
  --rose: #ffafb7;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #edf3fc;
  --surface: #fff;
  --surface-raised: #e0ebfb;
  --line: #c6d5e9;
  --text: #162741;
  --muted: #465b77;
  --accent: #145bb2;
  --accent-strong: #286bc4;
  --on-accent: #fff;
  --mint: #116750;
  --gold: #835400;
  --rose: #a82e42;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }
button, input { font: inherit; }
button { color: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
button:disabled { cursor: wait; opacity: .62; }
button[hidden], [hidden] { display: none !important; }
svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.app {
  max-width: 740px;
  margin: auto;
  min-height: 100dvh;
  min-height: var(--tg-viewport-stable-height, 100dvh);
  display: flex;
  flex-direction: column;
  padding-inline: max(16px, env(safe-area-inset-left), var(--tg-content-safe-area-inset-left, 0px))
                  max(16px, env(safe-area-inset-right), var(--tg-content-safe-area-inset-right, 0px));
  padding-top: max(12px, var(--tg-content-safe-area-inset-top, 0px));
}
.brand { display: flex; gap: 11px; align-items: center; padding: 8px 0 12px; }
.brand-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 14px; background: var(--surface-raised); color: var(--accent); }
.brand-name, .brand-detail { display: block; }
.brand-name { font-weight: 780; letter-spacing: -.025em; }
.brand-detail, .eyebrow { font-size: .66rem; letter-spacing: .13em; color: var(--muted); font-weight: 730; }
.brand-detail { margin-top: 3px; }
.icon-button {
  min-width: 44px; min-height: 44px; border: 1px solid var(--line);
  background: var(--surface); border-radius: 14px; display: grid; place-items: center; margin-left: auto; color: var(--accent);
}
main { flex: 1; min-width: 0; padding: 10px 0 20px; }
h1, h2, p { margin: 0; overflow-wrap: anywhere; }
h1 { font-size: clamp(1.62rem, 7.4vw, 2.25rem); letter-spacing: -.042em; line-height: 1.12; }
h2 { font-size: 1.02rem; }
.eyebrow { margin-bottom: 8px; color: var(--accent); }
.muted { color: var(--muted); line-height: 1.45; }
.hero { background: linear-gradient(145deg, var(--surface-raised), var(--surface)); border: 1px solid var(--line); border-radius: 22px; padding: 17px; margin: 2px 0 14px; }
.hero .muted { margin-top: 9px; font-size: .83rem; }
.signal { display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; background: var(--mint); vertical-align: 1px; }
.signal.stale { background: var(--gold); }
.search { display: flex; align-items: center; gap: 9px; padding: 0 13px; min-height: 48px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); color: var(--muted); }
.search input { width: 100%; min-width: 0; border: 0; background: none; color: var(--text); padding: 11px 0; outline: none; }
.search input::placeholder { color: var(--muted); }
.material-filters summary { cursor: pointer; font-weight: 650; }
.filter-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; margin-top: 10px; }
.filter-fields label { display: grid; gap: 4px; min-width: 0; }
.filter-fields input, .filter-fields select { width: 100%; min-width: 0; min-height: 38px; padding: 5px; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; font: inherit; }
.filter-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.filter-chip { min-height: 36px; padding-block: 4px; }
.login-form { display: grid; gap: 13px; }
.login-options { display: grid; gap: 8px; }
.biometric-settings { display: flex; justify-content: flex-end; }
.biometric-settings .button { padding-inline: 12px; }
.workspace-settings { display: flex; gap: .45rem; flex-wrap: wrap; justify-content: flex-end; }
.workspace-settings #home-shortcut { padding-inline: 12px; }
.device-enrollment { max-width: 280px; }
.device-enrollment summary { display: list-item; cursor: pointer; }
.device-enrollment label { display: grid; gap: 4px; margin: .5rem 0; }
.device-enrollment input { width: 100%; padding: .5rem; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 9px; }
.login-form label { display: grid; gap: 6px; }
.login-form input {
  width: 100%; min-height: 46px; background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 11px; padding: 9px 12px;
}
.login-error { color: var(--rose); }
.login-error:empty { display: none; }
.logout { min-width: 60px; }
.search:focus-within { border-color: var(--accent); }
.list-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 16px 0 9px; }
.count { font-size: .76rem; font-weight: 720; color: var(--accent); background: var(--surface-raised); border-radius: 99px; padding: 4px 9px; white-space: nowrap; }
.list { display: grid; gap: 8px; }
.item { border: 1px solid var(--line); background: var(--surface); border-radius: 16px; padding: 11px 12px; width: 100%; text-align: left; display: grid; gap: 6px; min-height: 72px; }
.item:active, .button:active { background: var(--surface-raised); }
.item-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; min-width: 0; }
.item-title { font-size: .94rem; font-weight: 760; }
.chevron { flex: none; color: var(--accent); line-height: 1; }
.small { font-size: .78rem; line-height: 1.35; overflow-wrap: anywhere; }
.chip { display: inline-block; width: fit-content; max-width: 100%; color: var(--accent); background: var(--surface-raised); padding: 4px 8px; border-radius: 8px; font-weight: 650; }
.chip.green { color: var(--mint); } .chip.yellow { color: var(--gold); } .chip.red { color: var(--rose); }
.material-label { display: block; font-weight: 700; }
.hero .material-label { margin-top: 6px; }
.label-button { margin-top: 10px; color: var(--accent); }
.label-editor { display: grid; gap: 9px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.label-editor label { display: grid; gap: 5px; }
.label-editor input[type="text"] { min-width: 0; width: 100%; min-height: 44px; padding: 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--text); }
.label-editor .label-color { display: flex; align-items: center; justify-content: space-between; }
.label-color input { width: 52px; height: 44px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); padding: 4px; }
.label-controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.label-delete { grid-column: 1 / -1; }
.label-error, .label-delete { color: var(--rose); }
.label-error:empty, .label-editor .material-label:empty { display: none; }
.empty, .section { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px; margin: 10px 0; }
.empty p, .section p { line-height: 1.5; }
.section ul { margin: 8px 0 0; padding-left: 18px; line-height: 1.5; }
.section h2 + .muted { margin-top: 6px; }
.actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 12px 0; }
.button { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); min-height: 44px; padding: 8px 10px; font-size: .83rem; font-weight: 700; overflow-wrap: anywhere; }
.button.primary { background: var(--accent-strong); color: var(--on-accent); border-color: transparent; }
.button.back { color: var(--accent); margin-bottom: 12px; }
.notice { position: sticky; bottom: 70px; background: var(--surface-raised); border: 1px solid var(--line); border-radius: 13px; padding: 11px 13px; margin-bottom: 5px; font-size: .83rem; }
.nav { position: sticky; bottom: 0; background: var(--bg); border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; padding-top: 6px; padding-bottom: max(6px, env(safe-area-inset-bottom), var(--tg-content-safe-area-inset-bottom, 0px)); }
.nav button { min-height: 49px; min-width: 0; border: 0; background: none; border-radius: 12px; display: grid; place-items: center; align-content: center; gap: 4px; font-size: .72rem; font-weight: 670; color: var(--muted); }
.nav button[aria-current="page"] { background: var(--surface-raised); color: var(--accent); }
@media (min-width: 550px) {
  .app { padding-inline: 24px; }
  .list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 340px) {
  .app { padding-inline: 12px; }
  .hero { padding: 14px; }
  .nav button { font-size: .66rem; }
}
.pdf-controls {
  display: grid;
  grid-template-columns: 3rem minmax(0, 1fr) 3rem;
  align-items: center;
  gap: .5rem;
  margin-block: .65rem;
  text-align: center;
}
.pdf-image { display: block; width: 100%; height: 100%; object-fit: contain; background: white; border-radius: .5rem; }
.pdf-sheet { position: relative; margin-top: .6rem; background: var(--surface); border-radius: .5rem; }
.pdf-sheet:empty { border: 1px solid var(--line); }
.pdf-sheet > button { margin: 1rem; }
.pdf-viewport { overflow-x: auto; }
.pdf-group + .pdf-group { margin-top: 1.4rem; }
.pdf-section-title { color: var(--accent-strong); margin: .65rem 0; }
.pdf-toolbar { position: sticky; top: var(--tg-content-safe-area-inset-top, 0px); z-index: 2; background: var(--bg); padding: .3rem 0; }
.pdf-toolbar .pdf-search-panel { margin-block: 0; padding: .5rem; }
.pdf-toolbar > .pdf-controls { margin-block: .35rem 0; }
.pdf-toolbar .button { min-height: 36px; padding-block: .3rem; }
.pdf-viewport[data-zoom="150"] .pdf-sheet { width: 150%; }
.pdf-viewport[data-zoom="200"] .pdf-sheet { width: 200%; }
.pdf-viewport[data-zoom="250"] .pdf-sheet { width: 250%; }
.pdf-sheet svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; fill: #ffb000; fill-opacity: .43; }
.pdf-search { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .45rem; }
.pdf-search input {
  min-width: 0; width: 100%; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px; padding: .55rem .65rem;
}
.pdf-search-panel > .button { margin-top: .55rem; }
