/* lnote.ru — стили без внешних библиотек */

:root {
    --accent: #0EBED5;
    --accent-strong: #0A97AA;
    --ink: #22313F;
    --slate: #34495E;
    --muted: #6B7C8C;
    --bg: #F3F6F8;
    --paper: #FFFFFF;
    --line: #DDE4EA;
    --danger: #D64535;
    --ok: #1F9D5C;
    --focus: 0 0 0 3px rgba(14, 190, 213, .35);
    --radius: 10px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --accent: #2FD0E6;
        --accent-strong: #5CDCEE;
        --ink: #E4EBF1;
        --slate: #C9D5DF;
        --muted: #8FA0AF;
        --bg: #131A21;
        --paper: #1B242D;
        --line: #2C3844;
        --danger: #F06A5B;
        --ok: #3CC27E;
        color-scheme: dark;
    }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 16px/1.6 var(--font);
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: var(--accent-strong); }
a:hover { color: var(--accent); }

h1, h2 { line-height: 1.25; margin: 0 0 .5em; color: var(--slate); }

[hidden] { display: none !important; }

:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 6px; }

.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link { position: absolute; left: -9999px; }
.skip-link:focus { left: 12px; top: 12px; z-index: 100; background: var(--paper); padding: 8px 12px; }

.wrap { width: 100%; max-width: 980px; margin: 0 auto; padding: 0 16px; }
main.wrap { flex: 1; padding-top: 24px; padding-bottom: 40px; }

.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }

/* ---------- Иконки ---------- */
.ic {
    width: 1.1em; height: 1.1em; flex: none;
    fill: none; stroke: currentColor; stroke-width: 2;
    stroke-linecap: round; stroke-linejoin: round;
}

/* ---------- Кнопки ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .45em;
    padding: 9px 16px;
    font: inherit; font-weight: 600; font-size: .95rem; line-height: 1.2;
    border: 1px solid transparent; border-radius: 8px;
    background: none; color: var(--slate);
    cursor: pointer; text-decoration: none;
    transition: background-color .15s, color .15s, border-color .15s;
}
.btn:disabled { opacity: .6; cursor: default; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-strong); color: #fff; }
.btn-ghost { border-color: var(--line); background: var(--paper); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent-strong); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.08); color: #fff; }
.btn-sm { padding: 6px 10px; font-size: .85rem; }
.btn-block { width: 100%; }
.btn.is-done { border-color: var(--ok); color: var(--ok); }
.btn.is-loading { cursor: progress; }

/* ---------- Поля ---------- */
.input {
    display: block; width: 100%;
    padding: 10px 12px;
    font: inherit; color: var(--ink);
    background: var(--paper);
    border: 1px solid var(--line); border-radius: 8px;
    transition: border-color .15s, box-shadow .15s;
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
textarea.input { resize: vertical; min-height: 110px; }
.input.mono { font-family: var(--mono); font-size: .9rem; }

.field { margin-bottom: 16px; }
.field > label, .field-head label { display: block; font-weight: 600; margin-bottom: 6px; color: var(--slate); }
.field-head { display: flex; justify-content: space-between; align-items: baseline; }
.counter { font-size: .8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.counter.is-near { color: var(--danger); font-weight: 600; }
.field .btn-sm { margin-top: 8px; }

.hp-field { position: absolute !important; left: -10000px !important; width: 1px; height: 1px; overflow: hidden; }

/* ---------- Сообщения ---------- */
.alert {
    display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
    padding: 12px 14px; margin-bottom: 16px;
    border-radius: 8px; border: 1px solid; background: var(--paper);
}
.alert-ok { border-color: var(--ok); color: var(--ok); }
.alert-error { border-color: var(--danger); color: var(--danger); }
.alert-close { border: 0; background: none; color: inherit; cursor: pointer; padding: 2px; }

.toast {
    position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
    max-width: calc(100% - 32px);
    padding: 12px 18px; border-radius: 8px;
    background: var(--slate); color: var(--bg);
    font-weight: 600; box-shadow: 0 6px 24px rgba(0, 0, 0, .2); z-index: 50;
}

/* ---------- Главная ---------- */
.hero { margin: 8px 0 24px; }
.hero h1 { font-size: clamp(1.8rem, 4vw, 2.4rem); letter-spacing: -.02em; margin-bottom: .25em; }
.hero h1::after {
    content: ""; display: block; width: 56px; height: 4px; margin-top: 12px;
    background: var(--accent); border-radius: 2px;
}
.hero p { margin: 0; color: var(--muted); max-width: 60ch; }

.toolbar, .topbar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; }
.toolbar { justify-content: space-between; }

.compose {
    background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 20px; margin-bottom: 24px;
}

.search { position: relative; margin-bottom: 20px; }
.search .ic { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search .input { padding-left: 42px; border-radius: 999px; }

/* ---------- Заметки ---------- */
.notes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }

.note {
    display: flex; flex-direction: column;
    background: var(--paper);
    border: 1px solid var(--line);
    border-top: 3px solid var(--slate);
    border-radius: var(--radius);
    padding: 16px 18px 12px;
    min-width: 0;
}
.note:hover { border-top-color: var(--accent); }

.note-title { font-size: 1.1rem; margin: 0 0 8px; overflow-wrap: anywhere; }
.note-title a { color: var(--slate); text-decoration: none; }
.note-title a:hover { color: var(--accent-strong); }

.note-content {
    flex: 1;
    white-space: pre-line;
    overflow-wrap: anywhere;
    line-height: 1.65;
}
.note-content a {
    color: var(--accent-strong);
    font-weight: 600;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
    word-break: break-all;
}
.note-content a:hover { color: var(--accent); text-decoration-thickness: 2px; }

.note-foot {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px;
    margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--line);
}
.note-foot time { font-size: .8rem; color: var(--muted); }
.note-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.note-actions .btn { padding: 5px 9px; font-size: .8rem; }
.btn-report { color: var(--muted); }
.btn-report:hover { color: var(--danger); border-color: var(--danger); }

.note--single { max-width: 760px; margin: 0 auto; padding: 24px 26px 16px; }
.note--single .note-title { font-size: 1.6rem; }
.note--single .note-content { font-size: 1.05rem; }

.notes-empty, .empty { text-align: center; color: var(--muted); padding: 40px 0; }
.empty h1 { color: var(--slate); }

.more { display: flex; justify-content: center; padding: 24px 0 0; min-height: 40px; }

.spinner {
    width: 28px; height: 28px; border-radius: 50%;
    border: 3px solid var(--line); border-top-color: var(--accent);
    animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Страница «О сервисе» ---------- */
.page {
    max-width: 760px; margin: 0 auto;
    background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 24px 26px;
}
.page-body { overflow-wrap: anywhere; }

/* ---------- Подвал ---------- */
.site-footer { border-top: 1px solid var(--line); color: var(--muted); font-size: .9rem; }
.site-footer-inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; padding-top: 20px; padding-bottom: 20px; }
.site-footer nav { display: flex; gap: 16px; }
.site-footer a { color: var(--slate); text-decoration: none; }
.site-footer a:hover { color: var(--accent-strong); text-decoration: underline; }

/* ---------- Админка ---------- */
.login {
    max-width: 380px; margin: 60px auto;
    background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px;
}
.login h1 { font-size: 1.4rem; display: flex; align-items: center; gap: 10px; }

.admin-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.admin-head h1 { margin: 0; font-size: 1.6rem; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.stat {
    background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 14px 16px; display: flex; flex-direction: column; color: var(--muted); font-size: .9rem;
}
.stat-num { font-size: 1.8rem; font-weight: 700; color: var(--slate); line-height: 1.1; }
.stat-alert { border-color: var(--danger); }
.stat-alert .stat-num { color: var(--danger); }

.tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.tabs a {
    padding: 10px 14px; color: var(--muted); text-decoration: none; font-weight: 600;
    border-bottom: 3px solid transparent; margin-bottom: -1px;
}
.tabs a:hover { color: var(--slate); }
.tabs a.active { color: var(--accent-strong); border-bottom-color: var(--accent); }

.admin-search { display: flex; gap: 8px; margin-bottom: 14px; }
.table-actions { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }

.table-wrap { overflow-x: auto; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { padding: 10px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
.table th { color: var(--muted); font-weight: 600; font-size: .8rem; }
.table tr:last-child td { border-bottom: 0; }
.cell-note { min-width: 260px; }
.cell-note summary { cursor: pointer; font-weight: 600; color: var(--slate); }
.cell-note .note-content { margin-top: 8px; font-size: .9rem; }

.row-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.table .row-actions { flex-wrap: nowrap; }

.badge {
    display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 999px;
    font-size: .75rem; font-weight: 600; background: var(--line); color: var(--slate);
}
.badge-alert { background: var(--danger); color: #fff; }

.pager { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 16px; }
.pager a, .pager span { padding: 6px 11px; border-radius: 6px; border: 1px solid var(--line); text-decoration: none; }
.pager .active { background: var(--accent); border-color: var(--accent); color: #fff; }

.report, .panel {
    background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 18px 20px; margin-bottom: 16px;
}
.panel h2 { font-size: 1.2rem; }
.panel textarea { margin-bottom: 12px; }
.report-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 8px; }
.report .note-content { margin-bottom: 10px; }
.report-reasons { font-size: .9rem; color: var(--muted); }

code { font-family: var(--mono); font-size: .85em; }

/* ---------- Сортировка ленты ---------- */
.sort-tabs { display: flex; gap: 4px; margin: -4px 0 18px; }
.sort-tabs a {
    padding: 6px 14px; border-radius: 999px; text-decoration: none;
    color: var(--muted); font-weight: 600; font-size: .9rem;
}
.sort-tabs a:hover { color: var(--slate); }
.sort-tabs a.active { background: var(--slate); color: var(--bg); }

/* ---------- Форма ---------- */
.field-note { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 8px; font-size: .85rem; }
.field-note .btn-sm { margin-top: 0; }
.check-private { margin: 0 0 16px; font-size: .95rem; }
.check-private input { width: 18px; height: 18px; accent-color: var(--accent); }

/* ---------- Реакции ---------- */
.reactions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.reaction {
    display: inline-flex; align-items: center; gap: 4px;
    min-width: 40px; height: 30px; padding: 0 9px;
    font: inherit; font-size: .9rem; line-height: 1;
    background: var(--bg); color: var(--slate);
    border: 1px solid var(--line); border-radius: 999px; cursor: pointer;
}
.reaction:hover { border-color: var(--accent); }
.reaction.is-mine { border-color: var(--accent); background: rgba(14, 190, 213, .14); }
.reaction-count { font-size: .8rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.reaction-count:empty { display: none; }
.reactions.is-busy { opacity: .6; pointer-events: none; }

/* ---------- Приватные и свои заметки ---------- */
.note-flag { display: flex; align-items: center; gap: 6px; margin: -2px 0 8px; font-size: .85rem; color: var(--muted); }
.secret-box {
    max-width: 760px; margin: 0 auto 16px; padding: 14px 18px;
    background: var(--paper); border: 1px dashed var(--accent); border-radius: var(--radius);
    font-size: .92rem;
}
.secret-box p { margin: 0 0 6px; }
.secret-link { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.secret-link code {
    padding: 4px 8px; border-radius: 6px; background: var(--bg);
    overflow-wrap: anywhere; user-select: all;
}
.btn-delete:hover { color: var(--danger); border-color: var(--danger); }
.row-center { justify-content: center; }

/* Ссылка на запрещённый домен — просто текст */
.link-blocked { color: var(--muted); text-decoration: line-through; overflow-wrap: anywhere; }

/* ---------- Адаптивность ---------- */
@media (max-width: 720px) {
    .notes { grid-template-columns: 1fr; }
    .stats { grid-template-columns: repeat(2, 1fr); }
    .note--single, .page { padding: 18px 16px 12px; }
    .note--single .note-title { font-size: 1.35rem; }
    .compose { padding: 16px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation-duration: .01ms !important; }
}
