/* === RESET + SCROLLBAR === */
* { margin: 0; padding: 0; box-sizing: border-box; }

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-track { background: var(--surface); }
html { scrollbar-width: thin; scrollbar-color: var(--border) var(--surface); }

/* === THEME: Dark (default) === */
:root {
    --bg: #141414;
    --bg-elevated: #0a0a0a;
    --card: #1C1A14;
    --surface: #272318;
    --primary: #EBBB40;
    --primary-hi: #FAE96F;
    --primary-muted: rgba(235, 187, 64, 0.12);
    --text: #D6D3D1;
    --text-secondary: rgba(214, 211, 209, 0.6);
    --text-th: #D4A85C;
    --border: #8C7039;
    --border-subtle: #272318;
    --success: #649c67;
    --error: #cf6679;
    --warning: #DF8D03;
    --radius: 8px;
    --radius-sm: 4px;
    --radius-lg: 12px;
    --gap-section: 2rem;
    --gap-card: 1.5rem;
    --gap-form: 0.75rem;
    --transition-fast: 150ms ease;
    --transition-base: 200ms ease;
    --focus-ring: 2px solid var(--primary);
    --focus-offset: 2px;
}

/* === THEME: Light === */
[data-theme="light"] {
    --bg: #FAFAF9;
    --bg-elevated: #FFFFFF;
    --card: #FFFFFF;
    --surface: #F5F3EE;
    --primary: #B8860B;
    --primary-hi: #D4A017;
    --primary-muted: rgba(184, 134, 11, 0.1);
    --text: #1C1A14;
    --text-secondary: rgba(28, 26, 20, 0.6);
    --text-th: #8C7039;
    --border: #D4C5A9;
    --border-subtle: #E7E5E4;
    --success: #2D7A34;
    --error: #C62828;
    --warning: #D97706;
}

@media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]) {
        --bg: #FAFAF9;
        --bg-elevated: #FFFFFF;
        --card: #FFFFFF;
        --surface: #F5F3EE;
        --primary: #B8860B;
        --primary-hi: #D4A017;
        --primary-muted: rgba(184, 134, 11, 0.1);
        --text: #1C1A14;
        --text-secondary: rgba(28, 26, 20, 0.6);
        --text-th: #8C7039;
        --border: #D4C5A9;
        --border-subtle: #E7E5E4;
        --success: #2D7A34;
        --error: #C62828;
        --warning: #D97706;
    }
}

/* === TYPOGRAPHY === */
body {
    font-family: Inter, system-ui, sans-serif;
    font-size: 0.9375rem;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
}

h1 {
    font-family: Inter, system-ui, sans-serif;
    font-weight: 500;
    font-size: 1.375rem;
    line-height: 1.3;
    color: var(--primary-hi);
    letter-spacing: -0.015em;
    margin-bottom: 0.75rem;
    margin-top: 1.5rem;
}

h2 {
    font-family: Inter, system-ui, sans-serif;
    font-weight: 400;
    font-size: 1.25rem;
    line-height: 1.4;
    color: var(--text);
    letter-spacing: -0.015em;
    margin-bottom: 0.75rem;
    margin-top: 2rem;
}

.logo-square {
    font-family: Montserrat, sans-serif;
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--bg);
    background: var(--primary);
    width: 36px;
    height: 36px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo-text {
    font-family: Montserrat, sans-serif;
    font-weight: 600;
    font-size: 1.2rem;
    color: var(--text);
    text-decoration: none;
    letter-spacing: -0.02em;
}

.logo-suffix {
    color: var(--primary-hi);
}

code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    color: var(--primary);
    word-break: break-all;
}

small {
    color: var(--text-secondary);
}

/* === LAYOUT === */
.container { max-width: 800px; margin: 0 auto; padding: 2rem; }

nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.header-links {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.header-links a {
    color: var(--text);
    text-decoration: none;
    font-size: 0.9rem;
}

.header-links a:hover {
    color: var(--primary);
}

header.container {
    position: relative;
}

header.container::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, #FAE96F 0%, rgba(235, 187, 64, 0.3) 40%, transparent 100%);
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

/* === BUTTONS === */
button {
    background: var(--primary);
    color: var(--bg);
    border: none;
    padding: 0.5rem 1rem;
    cursor: pointer;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    transition: background var(--transition-fast);
}

button:hover {
    background: var(--primary-hi);
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.publish-btn {
    width: 100%;
    background: var(--primary);
    color: var(--bg);
    border: none;
    border-radius: 10px;
    padding: 1rem;
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition-fast), transform 0.1s;
    margin-top: 0.5rem;
}

.publish-btn:hover {
    background: var(--primary-hi);
    transform: translateY(-1px);
}

.btn-bordered {
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.4rem 0.75rem;
    font-size: 0.85rem;
}

.btn-bordered:hover {
    border-color: var(--primary);
    background: rgba(235, 187, 64, 0.06);
}

.btn-text {
    background: transparent;
    color: var(--primary);
    border: none;
    position: relative;
    overflow: hidden;
    padding: 0.4rem 0.75rem;
    font-size: 0.85rem;
    cursor: pointer;
}

.btn-text::after {
    content: '';
    position: absolute;
    bottom: 4px;
    left: 20%;
    right: 20%;
    height: 1.5px;
    background: linear-gradient(90deg, transparent, #EBBB40, transparent);
    opacity: 0;
    transition: opacity 0.2s;
}

.btn-text:hover::after {
    opacity: 1;
}

.btn-destructive {
    background: transparent;
    color: var(--error);
    border: none;
    position: relative;
    overflow: hidden;
    padding: 0.4rem 0.75rem;
    font-size: 0.85rem;
    cursor: pointer;
}

.btn-destructive::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 15%;
    right: 15%;
    height: 1.5px;
    background: linear-gradient(90deg, transparent, #cf6679, #e88a9a, #cf6679, transparent);
    opacity: 0;
    transition: opacity 0.2s;
}

.btn-destructive:hover {
    background: rgba(207, 102, 121, 0.08);
}

.btn-destructive:hover::after {
    opacity: 1;
}

.btn-icon {
    width: 28px;
    height: 28px;
    padding: 0;
    background: transparent;
    color: var(--text);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: color var(--transition-fast);
}

.btn-icon:hover {
    color: var(--primary);
}

.btn-icon::before {
    content: '';
    position: absolute;
    inset: -8px;
}

.outline {
    border: 1px solid var(--primary);
    background: transparent;
    color: var(--primary);
    padding: 0.4rem 0.75rem;
    text-decoration: none;
    border-radius: var(--radius);
    font-size: 0.85rem;
    display: inline-block;
}

.outline:hover {
    background: var(--primary-muted);
}

/* === FORMS === */
textarea {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    padding: 0.75rem;
    border-radius: var(--radius);
    resize: vertical;
    line-height: 1.5;
}

input[type="text"],
input[type="password"] {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
}

input[type="text"]:disabled,
input[type="password"]:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.monospace {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8125rem;
}

.publish-settings {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin: 1rem 0;
}

.setting-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.setting-label {
    font-size: 0.85rem;
    min-width: 60px;
    color: var(--text);
}

.toggle-label {
    font-size: 0.85rem;
    color: var(--text);
    min-width: 80px;
}

/* === COMPONENTS: Cards === */
article {
    background: var(--card);
    border: 1px solid var(--border-subtle);
    padding: 1.25rem 1.5rem;
    border-radius: var(--radius);
}

article header {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 0.5rem;
    color: var(--text);
}

article footer {
    margin-top: 0.75rem;
}

.result-card {
    position: relative;
    overflow: hidden;
    background: var(--card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-top: 1.5rem;
    box-shadow: 0 6px 24px rgba(235, 187, 64, 0.08);
}

.result-card::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 10%;
    right: 10%;
    height: 2px;
    background: linear-gradient(90deg, transparent 0%, #EBBB40 30%, #FAE96F 50%, #EBBB40 70%, transparent 100%);
}

.result-card--success::after {
    background: linear-gradient(90deg, transparent, #649c67, #7ac47e, #649c67, transparent);
}

.result-card--success {
    box-shadow: 0 6px 24px rgba(100, 156, 103, 0.08);
}

.result-card--warning::after {
    background: linear-gradient(90deg, transparent, #F97316, #FDBA74, #F97316, transparent);
}

.result-card--warning {
    box-shadow: 0 6px 24px rgba(249, 115, 22, 0.08);
}

.result-card--error::after {
    background: linear-gradient(90deg, transparent, #cf6679, #e88a9a, #cf6679, transparent);
}

.result-card--error {
    box-shadow: 0 6px 24px rgba(207, 102, 121, 0.08);
}

.result-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.result-badge {
    background: var(--success);
    color: var(--bg);
    padding: 0.2rem 0.6rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
}

.result-meta {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.result-url-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.result-link {
    color: var(--primary);
    text-decoration: none;
    word-break: break-all;
}

.result-link:hover {
    text-decoration: underline;
}

.result-details {
    margin-top: 0.5rem;
}

.result-details-content {
    padding-top: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.result-detail-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.result-detail-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    min-width: 80px;
}

.result-owner-link {
    margin: 0.25rem 0;
}

.file-card {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.file-meta {
    font-size: 0.85rem;
    color: var(--text);
}

/* === COMPONENTS: Copy Button === */
.copy-btn {
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

.copy-btn.copied {
    color: var(--success);
}

.copy-icon.copied svg {
    stroke: var(--success);
}

/* === COMPONENTS: Badges === */
.more-badge {
    display: inline-block;
    background: var(--primary);
    color: var(--bg);
    width: 20px;
    height: 20px;
    border-radius: 50%;
    text-align: center;
    font-size: 0.75rem;
    line-height: 20px;
    cursor: pointer;
    position: relative;
    vertical-align: middle;
    margin-left: 0.25rem;
}

.more-tooltip {
    display: none;
    position: absolute;
    bottom: 130%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--card);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    padding: 0.75rem;
    min-width: 220px;
    z-index: 10;
    text-align: left;
}

.more-badge:hover .more-tooltip {
    display: block;
}

.more-tooltip-title {
    display: block;
    font-weight: 600;
    margin-bottom: 0.25rem;
    font-size: 0.85rem;
}

.more-tooltip-item {
    display: block;
    font-size: 0.8rem;
    margin-bottom: 0.25rem;
}

.more-tooltip-item span {
    display: inline-block;
    font-weight: 600;
    color: var(--primary);
    min-width: 40px;
}

/* === COMPONENTS: Toggle === */
.toggle-track {
    width: 40px;
    height: 22px;
    border-radius: 11px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    position: relative;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.toggle-track.on {
    background: var(--primary);
    border-color: var(--primary);
}

.toggle-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--border);
    position: absolute;
    top: 1.5px;
    left: 2px;
    transition: all 0.2s;
}

.toggle-track.on .toggle-thumb {
    background: var(--bg);
    left: 20px;
}

/* === COMPONENTS: TTL Slider === */
.ttl-slider-wrap {
    display: flex;
    align-items: center;
    gap: 0.625rem;
}

.ttl-range {
    -webkit-appearance: none;
    appearance: none;
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: var(--surface);
    outline: none;
    cursor: pointer;
}

.ttl-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary);
    border: 2px solid var(--bg);
    box-shadow: 0 0 0 2px var(--border);
    cursor: pointer;
}

.ttl-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    color: var(--primary);
    min-width: 3.5rem;
    text-align: right;
}

/* === COMPONENTS: Drop Zone === */
.drop-zone {
    border: 2px dashed var(--border);
    border-radius: 10px;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: border-color var(--transition-base), background var(--transition-base);
    margin-top: 0.75rem;
    color: var(--text);
    font-size: 0.9rem;
}

.drop-zone:hover,
.drop-zone.dragover {
    border-color: var(--primary);
    background: var(--primary-muted);
}

/* === SECTIONS: Hero, Publish, Result, Advanced Panel, Tabs, LLM, Examples, Footer, Password Viewer === */
#hero h1 {
    font-size: 1.375rem;
    color: var(--primary-hi);
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
}

#hero p {
    font-size: 1.1rem;
    position: relative;
}

#result {
    margin-top: 1.5rem;
}

#result header {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--success);
    margin-bottom: 0.75rem;
}

.result-url {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.result-url input {
    flex: 1;
    margin-bottom: 0;
}

details summary {
    cursor: pointer;
    color: var(--primary);
    margin: 0.5rem 0;
    font-size: 0.9rem;
}

.advanced-panel {
    background: var(--card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    margin-top: 2rem;
}

.advanced-panel h2 {
    padding: 1.5rem 1.5rem 0;
    margin-top: 0;
}

.advanced-panel article {
    padding: 1.5rem;
    margin: 1rem 1.5rem;
}

.tab-bar {
    display: flex;
    border-bottom: 1px solid var(--border-subtle);
    margin: 0 1.5rem;
}

.tab-item {
    padding: 0.5rem 1rem;
    color: var(--text-secondary);
    position: relative;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    transition: color var(--transition-fast);
}

.tab-item:hover {
    color: var(--text);
}

.tab-item.active {
    color: var(--primary);
}

.tab-item.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 5%;
    right: 5%;
    height: 2px;
    background: linear-gradient(90deg, transparent, #EBBB40, #FAE96F, #EBBB40, transparent);
}

.tab-content {
    padding: 1.5rem;
}

.llm-block {
    margin-top: 3rem;
}

.agent-section {
    margin-top: 1.5rem;
}

.agent-title {
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.agent-snippet {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.875rem 1.25rem;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    color: var(--primary);
    line-height: 1.6;
    position: relative;
    white-space: pre-line;
}

.agent-copy {
    position: absolute;
    top: 0.5rem;
    right: 0.75rem;
    cursor: pointer;
    font-size: 0.75rem;
    color: var(--text);
    font-family: Inter, system-ui, sans-serif;
}

.agent-copy:hover {
    color: var(--primary);
}

.agent-tools {
    margin-top: 0.75rem;
    font-size: 0.85rem;
    color: var(--text);
}

.examples-grid article {
    min-height: 120px;
}

footer.container {
    margin-top: 3rem;
}

footer.container hr {
    border-color: var(--surface);
    margin-bottom: 1rem;
}

footer.container small {
    font-size: 0.85rem;
}

footer a {
    color: var(--primary);
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

#file-notification {
    background: var(--card);
    border: 1px solid var(--success);
    border-radius: var(--radius);
    padding: 1rem;
    margin-top: 1rem;
    display: none;
}

#file-notification.visible {
    display: block;
}

#password-viewer-form {
    max-width: 400px;
    margin: 4rem auto;
    text-align: center;
    padding: 2rem;
}

#password-viewer-form h2 {
    margin-top: 0;
}

#password-viewer-form p {
    margin: 0.75rem 0;
}

#password-viewer-form .setting-row {
    justify-content: center;
    margin-top: 1rem;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

th, td {
    padding: 0.5rem;
    border-bottom: 1px solid var(--surface);
    text-align: left;
}

th {
    color: var(--text-th);
    font-size: 0.85rem;
    font-weight: 600;
}

tr:hover {
    background: var(--primary-muted);
}

.kv-delete-cell {
    text-align: right;
}

.kv-info, .json-info {
    font-size: 0.85rem;
    color: var(--text);
    margin: 0.5rem 0;
}

#kv-owner-token-info,
#json-owner-token-info {
    background: var(--surface);
    padding: 0.75rem;
    border-radius: var(--radius);
    margin: 0.5rem 0;
    word-break: break-all;
    font-size: 0.85rem;
}

#json-error {
    color: var(--error);
    font-size: 0.85rem;
    min-height: 1.2em;
    display: block;
    margin-top: 0.25rem;
}

#preview {
    width: 100%;
    min-height: 300px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-top: 1rem;
    background: #fff;
}

/* === UTILITY === */
.truncate {
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hidden {
    display: none;
}

[hidden] {
    display: none !important;
}

hr {
    border-color: var(--surface);
    margin: 1.5rem 0;
}

:focus-visible {
    outline: var(--focus-ring);
    outline-offset: var(--focus-offset);
}

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