/* Спільні стилі внутрішніх інструментів Aditus (narzedzia, kyb-generator, zvit-generator, dokumenty).
   Підключається ПІСЛЯ /fonts-blog.css. Шрифти: лише локальні (RODO), без Google Fonts.
   Лише вигляд: логіка сторінок (id, data-*, класи станів .on/.show/.copied/.st-*) не залежить від цього файлу.
   Стилі, специфічні для сторінки, лишаються inline у самій сторінці. */
:root {
  --ink: #0d1b4b; --accent: #162d7a; --gold: #c9a84c; --gold-soft: #f3ead0;
  --paper: #faf8f3; --card: #ffffff; --line: #e7e2d4; --line-soft: #efebe0;
  --slate: #4a5568; --muted: #6b665a; --gold-ink: #7d6317;
  --ok: #2f6b4a; --ok-bg: #e9f3ec; --warn: #7a5c20; --warn-bg: #f7f0e3; --err: #a03e3e; --err-bg: #f7ebea;
  --radius: 18px; --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(13,27,75,.04), 0 8px 24px -12px rgba(13,27,75,.10);
  --page-w: 960px;
  /* аліаси старих назв змінних, щоб inline-правила сторінок не зламались */
  --mist: var(--line); --white: #ffffff; --error: var(--err); --error-bg: var(--err-bg);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { font-family: 'DM Sans', system-ui, sans-serif; background: var(--paper); color: var(--ink); min-height: 100vh; min-height: 100dvh;
       line-height: 1.5; padding-bottom: env(safe-area-inset-bottom); }
a { color: var(--accent); }
.mono { font-family: 'IBM Plex Mono', ui-monospace, monospace; }

/* ---------- екран пароля ---------- */
#gate { position: fixed; inset: 0; background: var(--paper); display: flex; align-items: center; justify-content: center; z-index: 1000;
        padding: calc(24px + env(safe-area-inset-top)) 20px calc(24px + env(safe-area-inset-bottom)); overflow: hidden; }
#gate::before { content: ""; position: absolute; right: -120px; top: -120px; width: 420px; height: 420px; border-radius: 50%; border: 1px solid rgba(201,168,76,.4); pointer-events: none; }
#gate::after { content: ""; position: absolute; right: -50px; top: -50px; width: 280px; height: 280px; border-radius: 50%; border: 1px solid rgba(201,168,76,.22); pointer-events: none; }
.gate-card { position: relative; z-index: 1; width: 100%; max-width: 400px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
             box-shadow: var(--shadow); padding: 40px 32px 32px; text-align: center; }
.gate-logo { font-family: 'Playfair Display', serif; font-weight: 700; font-size: 24px; letter-spacing: -.01em; color: var(--ink); margin-bottom: 6px; }
.gate-logo span, .tool-logo span { color: var(--gold); font-style: italic; font-weight: 500; }
.gate-eyebrow { font: 500 11px 'IBM Plex Mono', monospace; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); margin-bottom: 26px; }
.gate-card label { display: block; color: var(--slate) !important; text-align: left; font: 500 11px 'IBM Plex Mono', monospace; letter-spacing: .1em; text-transform: uppercase; margin-bottom: 8px !important; }
.gate-card input { width: 100%; padding: 13px 14px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: #fff; color: var(--ink);
                   font-size: 15px; outline: none; text-align: center; letter-spacing: 2px; transition: border-color .15s, box-shadow .15s; }
.gate-card input:focus { border-color: var(--gold); box-shadow: 0 0 0 4px var(--gold-soft); }
.gate-card button { width: 100%; margin-top: 14px; background: var(--ink); color: #fff; min-height: 46px; }
.gate-card button:hover { background: var(--accent); }
.gate-error { margin-top: 14px; font-size: 13px; color: var(--err); min-height: 18px; }
.gate-note { margin-top: 18px; font-size: 12.5px; line-height: 1.55; color: var(--muted); text-align: left; font-weight: 300; }

/* ---------- шапка й навігація ---------- */
#app { display: none; }
#app.show { display: block; }
.tool-header { position: sticky; top: 0; z-index: 20; background: rgba(250,248,243,.9); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
               border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px 14px;
               padding: calc(14px + env(safe-area-inset-top)) max(24px, calc((100% - var(--page-w)) / 2)) 14px; }
.tool-logo { font-family: 'Playfair Display', serif; font-weight: 700; font-size: 20px; letter-spacing: -.01em; color: var(--ink); }
.tool-nav { display: flex; gap: 6px; flex-wrap: wrap; }
.tool-nav a { font: 500 11.5px 'IBM Plex Mono', monospace; letter-spacing: .08em; text-transform: uppercase; color: var(--slate); background: transparent;
              border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; min-height: 36px; display: inline-flex; align-items: center;
              text-decoration: none; transition: .15s; }
.tool-nav a:hover { border-color: var(--gold); color: var(--ink); }
.tool-nav a.active { background: var(--ink); border-color: var(--ink); color: #fff; }

.wrap, .tool-wrap { max-width: var(--page-w); margin: 0 auto; padding: 48px 24px 96px; }

/* ---------- типографіка ---------- */
.tag { display: inline-flex; align-items: center; gap: 8px; font: 500 11px 'IBM Plex Mono', monospace; letter-spacing: .14em; text-transform: uppercase;
       color: var(--slate); border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px 5px 10px; background: var(--card); }
.tag i { font-style: normal; color: var(--gold-ink); }
h1 { font-family: 'Playfair Display', serif; font-weight: 600; font-size: clamp(30px, 4.6vw, 44px); line-height: 1.1; letter-spacing: -.02em; margin: 16px 0 14px; }
h1 em { font-style: italic; color: var(--accent); font-weight: 500; }
h2 { font-family: 'Playfair Display', serif; font-weight: 600; font-size: 22px; line-height: 1.2; letter-spacing: -.01em; margin: 0 0 14px; }
h3 { font-family: 'Playfair Display', serif; font-weight: 600; font-size: 17px; margin: 18px 0 8px; }
.lede { color: var(--slate); font-size: 16px; line-height: 1.65; max-width: 62ch; font-weight: 300; margin-bottom: 32px; }
.hint { font-size: 13px; color: var(--slate); line-height: 1.55; font-weight: 300; margin-top: 8px; }
.note { font: 400 11px 'IBM Plex Mono', monospace; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.tool-footer { text-align: center; margin-top: 48px; font: 400 11px 'IBM Plex Mono', monospace; letter-spacing: .06em; color: var(--muted); }

/* ---------- картки (з автоматичною міткою § 01, 02… без зміни розмітки) ---------- */
.wrap, .tool-wrap { counter-reset: sec; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; margin-bottom: 20px; box-shadow: var(--shadow); }
.card > h2:first-child::before { counter-increment: sec; content: "§ " counter(sec, decimal-leading-zero); display: block; width: max-content; margin-bottom: 12px;
        font: 500 11px 'IBM Plex Mono', monospace; letter-spacing: .14em; text-transform: uppercase; color: var(--gold-ink);
        border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; background: var(--card); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.actions { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; align-items: center; }

/* ---------- форми ---------- */
label.lbl { display: block; font: 500 11px 'IBM Plex Mono', monospace; letter-spacing: .1em; text-transform: uppercase; color: var(--slate); margin-bottom: 8px; }
input[type="text"], input[type="date"], input[type="number"], input[type="search"], input[type="password"], textarea, select {
  width: 100%; font: 400 15px 'IBM Plex Mono', monospace; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: #fff; color: var(--ink); outline: none; transition: border-color .15s, box-shadow .15s; }
textarea { font-family: 'DM Sans', sans-serif; line-height: 1.55; resize: vertical; min-height: 88px; }
select { font-family: 'DM Sans', sans-serif; }
input:focus, textarea:focus, select:focus { border-color: var(--gold); box-shadow: 0 0 0 4px var(--gold-soft); }
::placeholder { color: #b4ae9d; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); }
.check-inline { display: inline-flex; gap: 8px; align-items: center; font-size: 14px; color: var(--slate); min-height: 40px; }
.check-inline input { width: 18px; height: 18px; }

/* ---------- кнопки ---------- */
button { font: 600 14px 'DM Sans', sans-serif; border: 1px solid transparent; border-radius: 999px; padding: 11px 22px; cursor: pointer; transition: .15s; }
button:disabled { cursor: not-allowed; opacity: .45; }
.btn-primary { background: var(--ink); color: #fff; min-height: 46px; padding: 0 24px; }
.btn-primary:hover:not(:disabled) { background: var(--accent); box-shadow: 0 8px 20px -10px rgba(13,27,75,.6); }
.btn-gold { background: var(--gold); color: var(--ink); min-height: 46px; padding: 0 24px; }
.btn-gold:hover:not(:disabled) { filter: brightness(1.05); }
.btn-ghost { background: transparent; color: var(--slate); border-color: var(--line); min-height: 46px; padding: 0 22px; }
.btn-ghost:hover:not(:disabled) { border-color: var(--slate); color: var(--ink); }
.btn-mini { font: 500 13px 'DM Sans', sans-serif; padding: 0 16px; min-height: 38px; border-radius: 999px; border: 1px solid var(--line); background: #fff;
            color: var(--slate); cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; transition: .15s; }
.btn-mini:hover:not(:disabled) { border-color: var(--gold); color: var(--ink); }

/* ---------- статуси ---------- */
.status { margin-top: 14px; padding: 12px 16px; border-radius: 12px; font-size: 14px; line-height: 1.5; display: none; }
.status.show { display: block; }
.status.loading { background: var(--paper); border: 1px solid var(--line); color: var(--slate); }
.status.error { background: var(--err-bg); color: var(--err); }
.status.warn { background: var(--warn-bg); color: var(--warn); }
.status.ok { background: var(--ok-bg); color: var(--ok); }
.spinner { display: inline-block; width: 12px; height: 12px; border: 2px solid var(--line); border-top-color: var(--gold); border-radius: 50%; animation: spin .8s linear infinite; margin-right: 8px; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- об'єкт перевірки ---------- */
.subject { background: var(--ink); color: #fff; border-radius: var(--radius); padding: 30px; margin-bottom: 20px; position: relative; overflow: hidden; }
.subject::after { content: ""; position: absolute; right: -60px; top: -60px; width: 220px; height: 220px; border-radius: 50%; border: 1px solid rgba(201,168,76,.35); pointer-events: none; }
.subject::before { content: ""; position: absolute; right: -20px; top: -20px; width: 140px; height: 140px; border-radius: 50%; border: 1px solid rgba(201,168,76,.2); pointer-events: none; }
.subject .eyebrow { font: 500 11px 'IBM Plex Mono', monospace; letter-spacing: .2em; text-transform: uppercase; color: var(--gold); position: relative; z-index: 1; }
.subject .title { font-family: 'Playfair Display', serif; font-weight: 600; font-size: clamp(24px, 4vw, 32px); letter-spacing: -.01em; margin: 10px 0; position: relative; z-index: 1; }
.subject .meta { font: 400 12px 'IBM Plex Mono', monospace; color: rgba(255,255,255,.65); line-height: 1.8; overflow-wrap: anywhere; position: relative; z-index: 1; }
.progress { height: 6px; background: rgba(255,255,255,.14); border-radius: 999px; margin-top: 22px; overflow: hidden; position: relative; z-index: 1; }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--gold), #e3c875); border-radius: 999px; width: 0; transition: width .4s; }
.progress-label { font: 400 12px 'IBM Plex Mono', monospace; color: rgba(255,255,255,.7); margin-top: 10px; position: relative; z-index: 1; }

/* ---------- знахідки, пігулки ---------- */
.finding { border: 1px solid var(--line-soft); border-radius: 14px; padding: 18px 20px; margin-bottom: 12px; background: var(--paper); }
.finding .fh { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; align-items: center; }
.finding .fid { font: 500 11px 'IBM Plex Mono', monospace; letter-spacing: .06em; color: var(--muted); overflow-wrap: anywhere; }
.finding .flines { margin-top: 10px; font-size: 14.5px; line-height: 1.6; }
.finding .flines div { border-bottom: 1px dotted var(--line); padding: 5px 0; }
.finding .flines div:last-child { border-bottom: none; }
.finding .fmeta { font-size: 12.5px; color: var(--muted); margin-top: 10px; overflow-wrap: anywhere; }
.alert { color: var(--err); font-weight: 600; }
.pill { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 500; padding: 4px 11px; border-radius: 999px; background: var(--line-soft); color: var(--slate); white-space: nowrap; }
.pill.clear::before, .pill.hit::before, .pill.wait::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .85; }
.pill.clear { background: var(--ok-bg); color: var(--ok); }
.pill.hit { background: var(--err-bg); color: var(--err); }
.pill.wait { background: var(--warn-bg); color: var(--warn); }

/* ---------- таблиці ---------- */
#sankBox { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.sank { width: 100%; border-collapse: collapse; font-size: 14.5px; min-width: 520px; }
table.sank th, table.sank td { text-align: left; padding: 14px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
table.sank th { font: 500 11px 'IBM Plex Mono', monospace; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
table.sank tr:last-child td { border-bottom: none; }
details.snip { margin-top: 8px; font-size: 12.5px; }
details.snip summary { cursor: pointer; color: var(--accent); }
details.snip pre { white-space: pre-wrap; font: 400 11.5px 'IBM Plex Mono', monospace; background: var(--paper); border: 1px solid var(--line-soft); border-radius: 10px;
                   padding: 10px; margin-top: 6px; max-height: 260px; overflow: auto; }

/* ---------- ручні пункти ---------- */
.task { border: 1px solid var(--line); border-radius: 16px; padding: 20px 20px 20px 24px; margin-bottom: 14px; background: #fff; position: relative; }
.task::before { content: ""; position: absolute; left: 0; top: 18px; bottom: 18px; width: 3px; border-radius: 3px; background: var(--line); }
.task.st-none::before { background: var(--ok); }
.task.st-found::before { background: #d98b3a; }
.task.st-na::before { background: var(--err); }
.task .th { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: center; }
.task .tt { font-weight: 600; font-size: 15.5px; }
.task .tn { font: 500 12px 'IBM Plex Mono', monospace; color: var(--gold-ink); letter-spacing: .1em; margin-right: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }
.chip { font: 400 13px 'IBM Plex Mono', monospace; background: var(--paper); border: 1px dashed #cfc8b4; padding: 8px 12px; border-radius: 999px; cursor: pointer; min-height: 38px;
        display: inline-flex; align-items: center; transition: .15s; }
.chip:hover { border-color: var(--gold); background: var(--gold-soft); }
.chip.copied { background: var(--ok-bg); border-color: var(--ok); color: var(--ok); }
.seg { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--line); border-radius: 999px; padding: 3px; gap: 3px; background: var(--paper); }
.seg button { font: 500 13px 'DM Sans', sans-serif; border: none; background: transparent; color: var(--slate); padding: 0 14px; min-height: 38px; border-radius: 999px; cursor: pointer; transition: .15s; }
.seg button:hover:not(.on):not(:disabled) { color: var(--ink); background: var(--line-soft); }
.seg button.on { background: var(--ink); color: #fff; }
.drop { margin-top: 14px; border: 1.5px dashed #cfc8b4; border-radius: 14px; padding: 16px; font-size: 13.5px; color: var(--slate); text-align: center; background: var(--paper); outline: none; transition: .15s; }
.drop:hover, .drop:focus, .drop.over { border-color: var(--gold); background: #fbf6e6; }
kbd { font: 500 11.5px 'IBM Plex Mono', monospace; background: #fff; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 6px; padding: 1px 6px; }

/* ---------- плитки хабу (narzedzia.html) ---------- */
.hub { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.tile { display: flex; flex-direction: column; gap: 10px; min-height: 190px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px;
        box-shadow: var(--shadow); text-decoration: none; color: var(--ink); transition: transform .18s, border-color .18s, box-shadow .18s; }
.tile:hover { transform: translateY(-3px); border-color: var(--gold); box-shadow: 0 1px 2px rgba(13,27,75,.04), 0 18px 36px -16px rgba(13,27,75,.18); }
.tile .n { font: 500 12px 'IBM Plex Mono', monospace; color: var(--gold-ink); letter-spacing: .14em; }
.tile h3 { font-family: 'Playfair Display', serif; font-weight: 600; font-size: 25px; line-height: 1.15; letter-spacing: -.01em; margin: 0; }
.tile h3 small { font: 500 .55em 'IBM Plex Mono', monospace; color: var(--gold-ink); letter-spacing: .1em; }
.tile p { color: var(--slate); font-size: 14.5px; font-weight: 300; line-height: 1.6; flex: 1; }
.tile .go { font: 500 12px 'IBM Plex Mono', monospace; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); }
.tile .go b { display: inline-block; transition: transform .18s; }
.tile:hover .go b { transform: translateX(4px); }

/* ---------- мобільна версія / PWA ---------- */
.task, .card { overflow-wrap: anywhere; }
@media (max-width: 720px) {
  .tool-header { position: static; padding-left: 16px; padding-right: 16px; flex-direction: column; align-items: stretch; }
  .tool-nav { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .tool-nav a { justify-content: center; text-align: center; min-height: 44px; }
  .wrap, .tool-wrap { padding: 32px 16px 72px; }
  .hub, .grid2, .grid3 { grid-template-columns: 1fr; }
  .card, .subject { padding: 22px 18px; }
  input, textarea, select { font-size: 16px !important; }
  button, .btn-mini, .seg button, .chip, a.btn-mini, label.btn-mini { min-height: 44px; }
  .seg { display: grid !important; grid-template-columns: 1fr 1fr; width: 100%; border-radius: 18px; }
  .seg button { width: 100%; min-width: 0; padding: 0 8px; border-radius: 14px; line-height: 1.2; }
  .fdel, .fren { min-height: 0 !important; width: 28px; height: 28px; padding: 0; line-height: 24px; }
  .actions .btn-mini, .actions button { flex: 1 1 100%; }
  .gate-card { padding: 32px 22px 26px; }
  table { max-width: 100%; }
}
