:root {
    --paper: #f3eee4;
    --paper-2: #fffaf3;
    --ink: #1c1915;
    --muted: #5c5348;
    --line: #d9cfc0;
    --pine: #1f3d34;
    --pine-2: #163028;
    --stamp: #9c3412;
    --code: #12261f;
    --code-ink: #e7f0ea;
    --shadow: 0 18px 40px rgba(28, 25, 21, 0.08);
    --serif: "Fraunces", "Palatino Linotype", Palatino, serif;
    --sans: "Source Sans 3", "Segoe UI", sans-serif;
    --mono: "IBM Plex Mono", Consolas, monospace;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    color: var(--ink);
    background:
        radial-gradient(circle at top left, rgba(156, 52, 18, 0.08), transparent 28rem),
        var(--paper);
    font-family: var(--sans);
    font-size: 1.05rem;
    line-height: 1.5;
}

a {
    color: var(--stamp);
}

img {
    display: block;
}

button,
input,
select,
textarea {
    font: inherit;
    color: inherit;
}

.skip {
    position: absolute;
    left: 1rem;
    top: -4rem;
    background: var(--paper-2);
    padding: 0.4rem 0.7rem;
}

.skip:focus {
    top: 0.5rem;
}

.mast {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--line);
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--ink);
    text-decoration: none;
    font-family: var(--serif);
    font-size: 1.7rem;
    font-weight: 680;
}

.brand img {
    width: 48px;
    height: 48px;
    object-fit: contain;
}

.mast nav {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.mast nav a {
    color: var(--pine);
    font-weight: 700;
    text-decoration: none;
}

.who {
    color: var(--muted);
}

main,
.workspace,
.editor-wrap {
    width: min(1220px, calc(100% - 2rem));
    margin: 0 auto;
}

.hero {
    padding: 2.5rem 0 1rem;
}

.hero h1,
.browse-head h1,
.gate h1,
.editor h1,
.reader h1,
.reading h1 {
    font-family: var(--serif);
    font-weight: 680;
    letter-spacing: -0.03em;
    line-height: 1.05;
    margin: 0.2rem 0 0.6rem;
}

.hero h1 {
    font-size: clamp(2.4rem, 5vw, 4.4rem);
    max-width: 16ch;
}

.kicker {
    margin: 0;
    color: var(--stamp);
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.notebook-search select.form-select {
    width: auto;
    min-width: 11rem;
    max-width: 16rem;
}

.searchbar {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 0.5rem 0.75rem;
    align-items: end;
    margin: 1.5rem 0;
}

.searchbar label {
    font-size: 0.85rem;
    font-weight: 700;
}

.searchbar .lang-label {
    grid-column: 2;
}

.searchbar input[type="search"] {
    grid-column: 1;
}

.searchbar select {
    grid-column: 2;
}

.searchbar button {
    grid-column: 3;
}

.searchbar output {
    grid-column: 1 / -1;
    color: var(--muted);
}

.compact {
    grid-template-columns: 1fr;
    margin: 0 0 1rem;
}

.compact .lang-label,
.compact select,
.compact button,
.compact input[type="search"] {
    grid-column: auto;
}

.browse-screen {
    width: min(1230px, calc(100% - 2rem));
    padding: 1.5rem 0 3rem;
}

.browse-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.browse-head h1 {
    font-size: clamp(2.4rem, 5vw, 4rem);
    margin: 0.15rem 0 0.35rem;
}

.browse-head .lede {
    max-width: 40rem;
    margin: 0;
}

.browse-screen .mine {
    grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
    margin-bottom: 1rem;
}

body:not(.is-editing) .editor-wrap {
    display: none;
}

body.is-editing #browse,
body.is-editing #searchScreen {
    display: none;
}

.editor-wrap {
    padding: 1.25rem 0 3rem;
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin: 0 0 0.9rem;
}

button.chip {
    background: transparent;
    color: var(--pine);
    border: 1px solid var(--pine);
    padding: 0.28rem 0.72rem;
    font-size: 0.85rem;
    font-weight: 700;
}

button.chip.on {
    background: var(--pine);
    color: #f7f3ea;
}

input[type="search"],
input[type="text"],
select,
textarea {
    width: 100%;
    background: var(--paper-2);
    border: 1px solid var(--line);
    border-radius: 0.4rem;
    padding: 0.55rem 0.7rem;
}

textarea {
    resize: vertical;
    min-height: 4.5rem;
}

button,
.mast nav a {
    border-radius: 999px;
}

button {
    background: var(--pine);
    color: #f7f3ea;
    border: 0;
    padding: 0.55rem 1rem;
    font-weight: 700;
    cursor: pointer;
}

button.secondary,
#newEntry,
#deleteEntry,
dialog button[value="cancel"] {
    background: transparent;
    color: var(--pine);
    border: 1px solid var(--pine);
}

#deleteEntry,
#confirmDelete {
    color: var(--stamp);
    border-color: var(--stamp);
    background: transparent;
}

#confirmDelete {
    background: var(--stamp);
    color: #fffaf3;
}

.shelf {
    list-style: none;
    padding: 0;
    margin: 0 0 3rem;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
    gap: 1rem;
}

.card {
    margin: 0;
}

.card-link {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    height: 100%;
    width: 100%;
    text-align: left;
    text-decoration: none;
    color: var(--ink);
    background: var(--paper-2);
    border: 1px solid var(--line);
    border-radius: 0.9rem;
    padding: 1rem;
    box-shadow: var(--shadow);
    cursor: pointer;
}

.card-link h3 {
    margin: 0;
    font-family: var(--serif);
    font-size: 1.35rem;
    line-height: 1.15;
}

.blurb,
.byline,
.empty,
.hint,
.lede {
    color: var(--muted);
}

.blurb,
.byline {
    margin: 0;
}

.stamp {
    margin: 0.4rem 0 0;
    align-self: flex-start;
    color: var(--stamp);
    border: 2px solid var(--stamp);
    border-radius: 0.3rem;
    padding: 0.05rem 0.4rem;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    transform: rotate(-2deg);
}

.empty {
    padding: 1rem 0 2rem;
}

.reader h2,
.block h2,
dialog h2 {
    font-family: var(--serif);
    margin: 0 0 0.4rem;
}

.gate {
    display: grid;
    place-items: center;
    min-height: calc(100vh - 6rem);
    width: min(40rem, calc(100% - 2rem));
}

.gate-card {
    background: var(--paper-2);
    border: 1px solid var(--line);
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.gate-card h1 {
    font-size: 2.4rem;
}

#googleButton {
    min-height: 44px;
    margin: 1rem 0;
}

.workspace {
    display: grid;
    grid-template-columns: minmax(16rem, 22rem) 1fr;
    gap: 1.5rem;
    padding: 1.25rem 0 3rem;
    width: min(1300px, calc(100% - 2rem));
}

.rail {
    min-width: 0;
}

.mine {
    grid-template-columns: 1fr;
}

.editor {
    background: var(--paper-2);
    border: 1px solid var(--line);
    border-radius: 1rem;
    padding: 1rem 1.1rem 1.4rem;
    box-shadow: var(--shadow);
}

.editor-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.8rem;
}

.editor-bar h1 {
    margin-right: auto;
    font-size: 2rem;
}

.editor label,
.editor .check {
    display: block;
    margin-top: 0.8rem;
    font-weight: 700;
}

.field-label {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin-top: 0.8rem;
}

.field-label label {
    margin-top: 0;
}

button.copy-code {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.8rem;
    height: 1.8rem;
    padding: 0;
    border-radius: 0.35rem;
    background: transparent;
    color: var(--pine);
    border: 1px solid var(--line);
}

.check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.check input {
    width: 1.1rem;
    height: 1.1rem;
}

.trio {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}

.trio label {
    margin-top: 0.4rem;
}

#code,
#html,
#css,
#sql,
#notes {
    font-family: var(--mono);
    font-size: 0.92rem;
    line-height: 1.45;
}

.danger-row {
    margin-top: 1.2rem;
}

.reading {
    padding-bottom: 3rem;
}

.reader {
    max-width: 52rem;
}

.back {
    margin-top: 1rem;
}

.block {
    margin: 1rem 0;
}

.block-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

pre {
    margin: 0;
    overflow: auto;
    background: var(--code);
    color: var(--code-ink);
    border-radius: 0.7rem;
    padding: 1rem;
}

code {
    font-family: var(--mono);
    font-size: 0.9rem;
    white-space: pre;
}

.copy {
    background: transparent;
    color: var(--pine);
    border: 1px solid var(--pine);
}

dialog {
    border: 1px solid var(--line);
    border-radius: 1rem;
    background: var(--paper-2);
    color: var(--ink);
    max-width: 28rem;
    padding: 1.2rem;
}

dialog::backdrop {
    background: rgba(28, 25, 21, 0.45);
}

.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

.quiet-form {
    display: none;
}

#errPanel {
    position: fixed;
    left: 1rem;
    bottom: 1rem;
    z-index: 20;
    width: min(28rem, calc(100% - 2rem));
    background: #fff6ee;
    color: var(--ink);
    border: 2px solid var(--stamp);
    border-radius: 0.8rem;
    padding: 0.9rem 1rem;
    box-shadow: var(--shadow);
}

#errPanel h2 {
    margin: 0 0 0.3rem;
    font-family: var(--serif);
    font-size: 1.3rem;
}

#errPanel pre {
    background: var(--paper);
    color: var(--ink);
    max-height: 8rem;
}

#errPanel .err-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.6rem;
}

:focus-visible {
    outline: 3px solid var(--stamp);
    outline-offset: 2px;
}

@media (max-width: 800px) {
    .searchbar,
    .trio,
    .workspace {
        grid-template-columns: 1fr;
    }

    .searchbar .lang-label,
    .searchbar select,
    .searchbar button,
    .searchbar input[type="search"] {
        grid-column: auto;
    }

    .mast,
    .browse-head {
        align-items: flex-start;
        flex-direction: column;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }
}

@media print {
    .mast,
    .searchbar,
    .copy,
    #errPanel {
        display: none;
    }

    body {
        background: #fff;
    }

    pre {
        color: #000;
        background: #fff;
        border: 1px solid #ccc;
    }
}

#entryTable.dataTable {
    table-layout: fixed !important;
    width: 1230px !important;
}

#entryTable.dataTable th,
#entryTable.dataTable td {
    box-sizing: border-box;
    overflow-wrap: anywhere;
    white-space: normal;
}

#entryTable col.col-edit,
#entryTable th:nth-child(1),
#entryTable td:nth-child(1) { width: 90px; }

#entryTable col.col-title,
#entryTable th:nth-child(2),
#entryTable td:nth-child(2) { width: 200px; }

#entryTable col.col-language,
#entryTable th:nth-child(3),
#entryTable td:nth-child(3) { width: 110px; }

#entryTable col.col-platform,
#entryTable th:nth-child(4),
#entryTable td:nth-child(4) { width: 110px; }

#entryTable col.col-scope,
#entryTable th:nth-child(5),
#entryTable td:nth-child(5) { width: 100px; }

#entryTable col.col-description,
#entryTable th:nth-child(6),
#entryTable td:nth-child(6) { width: 220px; }

#entryTable col.col-public,
#entryTable th:nth-child(7),
#entryTable td:nth-child(7) { width: 220px; }

#entryTable col.col-updated,
#entryTable th:nth-child(8),
#entryTable td:nth-child(8) {
    width: 180px;
    white-space: nowrap;
    overflow-wrap: normal;
}

#entryTable thead th {
    padding: 0.35rem;
    cursor: default;
    vertical-align: bottom;
    background-image: none;
}

#entryTable thead th.sorting:before,
#entryTable thead th.sorting:after,
#entryTable thead th.sorting_asc:before,
#entryTable thead th.sorting_asc:after,
#entryTable thead th.sorting_desc:before,
#entryTable thead th.sorting_desc:after,
#entryTable thead th.sorting_asc_disabled:before,
#entryTable thead th.sorting_asc_disabled:after,
#entryTable thead th.sorting_desc_disabled:before,
#entryTable thead th.sorting_desc_disabled:after {
    display: none !important;
    content: none !important;
}

#entryTable thead input.column-filter {
    display: block;
    width: 100% !important;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    margin: 0;
    padding: 0.35rem 0.5rem;
    font-size: 0.875rem;
    line-height: 1.4;
    border-radius: 0.25rem;
    background: #fff;
    color: var(--ink);
}

#entryTable thead input.column-filter::placeholder {
    color: #6c757d;
    opacity: 1;
}

#entryTable td.entry-description {
    white-space: normal;
}

#entryTable .entry-row {
    cursor: default;
}

#entryTable button.edit-entry,
#entryTable button.public-toggle {
    white-space: normal;
    line-height: 1.2;
}

#entryTable td:has(button.edit-entry),
#entryTable td:has(button.public-toggle) {
    text-align: center;
    vertical-align: middle;
}

#entryTable button.public-toggle,
#entryTable button.edit-entry {
    background: transparent;
    color: inherit;
    border: 0;
    padding: 0.25rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

#publicTable.dataTable {
    width: 100% !important;
}

.dataTables_wrapper {
    margin-top: 0.5rem;
}

.dataTables_wrapper > .row {
    margin-left: 0;
    margin-right: 0;
}

.dataTables_wrapper > .row > [class^="col-"] {
    padding-left: 0;
    padding-right: 0;
}

#mineList {
    overflow-x: auto;
}

.dataTables_wrapper .pagination {
    margin-bottom: 0;
}
