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

:root {
    --bg: #0b0b0c;
    --surface: #0f0f11;
    --surface-2: #151518;
    --border: #1f1f23;
    --border-strong: #303036;
    --text: #ededf0;
    --text-dim: #a1a1aa;
    --text-muted: #6b6b75;
    --primary: #fafafa;
    --primary-text: #09090b;
    --error: #f87171;
    --error-bg: rgba(248, 113, 113, 0.08);
    --error-border: rgba(248, 113, 113, 0.25);
    --success: #4ade80;

    --radius: 8px;
    --radius-sm: 6px;
    --ring: 0 0 0 3px rgba(255, 255, 255, 0.09);

    --font: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Helvetica, Arial, sans-serif;
    --mono: 'SF Mono', 'JetBrains Mono', 'Fira Code', 'Cascadia Code', Consolas, monospace;
}

html {
    -webkit-text-size-adjust: 100%;
    /* No elastic rubber-band past the top/bottom edges */
    overscroll-behavior: none;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    line-height: 1.5;
    min-height: 100vh;
    overscroll-behavior: none;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

::selection {
    background: rgba(255, 255, 255, 0.16);
}

/* Scrollbars */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) transparent;
}

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 999px;
    border: 3px solid transparent;
    background-clip: content-box;
}

::-webkit-scrollbar-thumb:hover {
    background: #45454d;
    background-clip: content-box;
    border: 3px solid transparent;
}

/* Two-column layout */
.layout {
    display: flex;
    min-height: 100vh;
}

.col-code {
    flex: 1;
    min-width: 0;
    border-right: 1px solid var(--border);
}

.col-sidebar {
    width: 320px;
    flex-shrink: 0;
    background: var(--surface);
}

.sidebar-inner {
    position: sticky;
    top: 0;
    padding: 28px;
    height: 100vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Brand */
.brand {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 0.9375rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--text);
    text-decoration: none;
    padding-bottom: 4px;
}

.brand::before {
    content: '';
    width: 9px;
    height: 9px;
    border-radius: 2px;
    background: var(--primary);
    flex-shrink: 0;
}

a.brand:hover {
    color: #fff;
}

/* File tree column */
.col-files {
    width: 240px;
    flex-shrink: 0;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: sticky;
    top: 0;
}

.files-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 16px 16px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--text-muted);
    flex-shrink: 0;
}

.btn-link {
    background: none;
    border: none;
    color: var(--text-muted);
    font: inherit;
    letter-spacing: inherit;
    cursor: pointer;
    padding: 0;
    transition: color 0.15s ease;
}

.btn-link:hover {
    color: var(--text);
}

.file-tree {
    overflow-y: auto;
    padding: 8px 8px 20px;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.tree-dir {
    font-family: var(--mono);
    font-size: 0.6875rem;
    color: var(--text-muted);
    padding: 12px 8px 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tree-file {
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-dim);
    font-family: var(--mono);
    font-size: 0.8125rem;
    padding: 6px 10px;
    cursor: pointer;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: background 0.12s ease, color 0.12s ease;
}

.tree-file:hover {
    background: var(--surface-2);
    color: var(--text);
}

.tree-file.active {
    background: var(--surface-2);
    color: var(--text);
}

.tree-file:focus-visible {
    outline: none;
    box-shadow: var(--ring);
}

/* Dropzone */
.dropzone {
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius);
    padding: 20px 14px;
    text-align: center;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.dropzone.dragging {
    border-color: var(--text-dim);
    background: var(--surface-2);
}

.dropzone.compact {
    padding: 12px;
}

.dropzone.compact .dz-text {
    display: none;
}

.dz-text {
    color: var(--text-muted);
    font-size: 0.8125rem;
    margin-bottom: 12px;
}

.dz-actions {
    display: flex;
    gap: 6px;
    justify-content: center;
}

.hint {
    color: var(--text-muted);
    font-size: 0.75rem;
    margin-top: 8px;
}

.hint:empty {
    display: none;
}

/* Buttons */
.btn {
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 9px 16px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    letter-spacing: -0.005em;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.06s ease, opacity 0.15s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    user-select: none;
}

.btn:hover {
    background: #1c1c20;
    border-color: var(--border-strong);
}

.btn:active {
    transform: translateY(1px);
}

.btn:focus-visible {
    outline: none;
    border-color: var(--border-strong);
    box-shadow: var(--ring);
}

.btn:disabled {
    opacity: 0.55;
    cursor: default;
    transform: none;
}

.btn-primary {
    background: var(--primary);
    color: var(--primary-text);
    border-color: var(--primary);
    font-weight: 600;
}

.btn-primary:hover {
    background: #fff;
    border-color: #fff;
}

.btn-primary:focus-visible {
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.22);
}

.btn-small {
    padding: 7px 12px;
    font-size: 0.8125rem;
}

.btn-full {
    width: 100%;
}

/* Form fields */
label {
    display: block;
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    margin-bottom: 7px;
}

.field-group {
    display: flex;
    flex-direction: column;
}

select,
input[type="password"],
input[type="text"] {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    outline: none;
    font-family: inherit;
    width: 100%;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input::placeholder {
    color: var(--text-muted);
}

select:hover,
input:hover {
    border-color: var(--border-strong);
}

select:focus,
input:focus {
    border-color: var(--border-strong);
    box-shadow: var(--ring);
}

select {
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    padding-right: 34px;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%236b6b75' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 11px center;
}

select option {
    background: var(--surface-2);
    color: var(--text);
}

/* CodeMirror */
#editor-wrap {
    height: 100vh;
    overflow: hidden;
}

#view-editor {
    min-height: 100vh;
}

#editor-wrap .CodeMirror,
#view-editor .CodeMirror {
    background: var(--bg);
    color: var(--text);
    font-family: var(--mono);
    font-size: 0.875rem;
    line-height: 1.65;
}

#editor-wrap .CodeMirror {
    height: 100%;
}

#view-editor .CodeMirror {
    min-height: 100vh;
    height: auto;
}

.CodeMirror-lines {
    padding: 14px 0;
}

/* Gutter shares the editor background so there is no seam.
   Selectors match the theme's own specificity (.cm-s-material-darker + class). */
.cm-s-material-darker .CodeMirror-gutters {
    background: var(--bg);
    border-right: 1px solid var(--border);
    padding-right: 4px;
}

.cm-s-material-darker .CodeMirror-linenumber {
    color: #3f3f47;
    font-size: 0.8125rem;
    padding: 0 10px 0 8px;
}

.cm-s-material-darker .CodeMirror-cursor {
    border-left: 2px solid var(--text);
}

.cm-s-material-darker div.CodeMirror-selected,
.cm-s-material-darker.CodeMirror-focused div.CodeMirror-selected {
    background: rgba(255, 255, 255, 0.09);
}

.cm-s-material-darker .CodeMirror-line::selection,
.cm-s-material-darker .CodeMirror-line > span::selection,
.cm-s-material-darker .CodeMirror-line > span > span::selection {
    background: rgba(255, 255, 255, 0.16);
}

.cm-s-material-darker .cm-comment {
    color: #5c5c66;
    font-style: italic;
}

/* Share result */
.result {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    animation: rise 0.22s ease-out;
}

.result label {
    margin-bottom: 0;
    color: var(--text-dim);
}

.result-row {
    display: flex;
    gap: 6px;
}

.result-row input {
    flex: 1;
    min-width: 0;
    background: var(--surface-2);
    font-family: var(--mono);
    font-size: 0.75rem;
    text-overflow: ellipsis;
}

@keyframes rise {
    from {
        opacity: 0;
        transform: translateY(4px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

.hidden {
    display: none !important;
}

.error {
    padding: 10px 13px;
    background: var(--error-bg);
    border: 1px solid var(--error-border);
    border-radius: var(--radius-sm);
    color: var(--error);
    font-size: 0.8125rem;
    animation: rise 0.22s ease-out;
}

.expiry-note {
    color: var(--text-muted);
    font-size: 0.75rem;
    text-align: center;
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

/* View sidebar */
.paste-title {
    font-size: 1.3125rem;
    font-weight: 650;
    line-height: 1.25;
    letter-spacing: -0.02em;
    word-break: break-word;
}

.meta-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: -8px;
}

.meta-date {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-top: -12px;
}

.lang-badge,
.lock-badge {
    display: inline-flex;
    align-items: center;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 3px 10px;
    font-size: 0.6875rem;
    font-weight: 500;
    letter-spacing: 0.03em;
    color: var(--text-dim);
    text-transform: uppercase;
}

.lock-badge::before {
    content: '';
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--text-muted);
    margin-right: 6px;
}

.sidebar-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: auto;
}

/* Password gate */
#password-gate {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
}

.gate-box {
    text-align: center;
    padding: 36px 32px;
    max-width: 400px;
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    animation: rise 0.25s ease-out;
}

.gate-box h2 {
    font-size: 1.25rem;
    font-weight: 650;
    letter-spacing: -0.02em;
    margin-bottom: 6px;
}

.gate-box p {
    color: var(--text-muted);
    margin-bottom: 22px;
    font-size: 0.875rem;
}

.password-form {
    display: flex;
    gap: 8px;
}

.password-form input {
    flex: 1;
    min-width: 0;
}

.gate-box .error {
    margin-top: 14px;
    text-align: left;
}

/* Not Found */
.not-found {
    text-align: center;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 24px;
}

.not-found h2 {
    font-size: 1.5rem;
    font-weight: 650;
    letter-spacing: -0.02em;
}

.not-found p {
    color: var(--text-muted);
    margin-bottom: 16px;
}

/* Responsive */
@media (max-width: 700px) {
    .layout {
        flex-direction: column;
        min-height: auto;
    }

    .col-code {
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    #editor-wrap {
        height: 55vh;
    }

    #view-editor,
    #view-editor .CodeMirror {
        min-height: 55vh;
    }

    .col-files {
        width: 100%;
        height: auto;
        position: static;
        border-right: none;
        border-bottom: 1px solid var(--border);
        max-height: 220px;
    }

    .col-sidebar {
        width: 100%;
    }

    .sidebar-inner {
        position: static;
        height: auto;
        padding: 22px 20px;
        gap: 18px;
    }

    .expiry-note {
        margin-top: 4px;
    }

    .sidebar-actions {
        margin-top: 4px;
    }
}

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