/* ── Tokens ─────────────────────────────────────────────── */
:root {
    --bg: #fafaf9;
    --surface: #ffffff;
    --surface-2: #f4f4f3;
    --border: #e7e5e4;
    --border-strong: #d6d3d1;
    --text: #1c1917;
    --text-muted: #78716c;
    --text-faint: #a8a29e;
    --accent: #4f46e5;
    --accent-hover: #4338ca;
    --accent-fg: #ffffff;
    --accent-soft: rgba(79, 70, 229, 0.08);
    --success: #15803d;
    --success-soft: rgba(21, 128, 61, 0.10);
    --error: #b91c1c;
    --error-soft: #fef2f2;
    --error-border: #fecaca;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 24px -8px rgba(0,0,0,0.10), 0 1px 2px rgba(0,0,0,0.04);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-xs: 6px;
    --font: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0c0a09;
        --surface: #1c1917;
        --surface-2: #292524;
        --border: #292524;
        --border-strong: #44403c;
        --text: #fafaf9;
        --text-muted: #a8a29e;
        --text-faint: #78716c;
        --accent: #818cf8;
        --accent-hover: #a5b4fc;
        --accent-fg: #1e1b4b;
        --accent-soft: rgba(129, 140, 248, 0.12);
        --success: #4ade80;
        --success-soft: rgba(74, 222, 128, 0.12);
        --error: #fca5a5;
        --error-soft: rgba(220, 38, 38, 0.12);
        --error-border: rgba(220, 38, 38, 0.30);
        --shadow-sm: 0 1px 2px rgba(0,0,0,0.30);
        --shadow-md: 0 8px 32px -12px rgba(0,0,0,0.50), 0 1px 2px rgba(0,0,0,0.30);
    }
}

/* ── Reset ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}
button { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ─────────────────────────────────────────────── */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.875rem 1.5rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.625rem;
    color: var(--text);
    font-weight: 600;
    font-size: 0.95rem;
    letter-spacing: -0.01em;
}
.brand:hover { text-decoration: none; }
.brand-mark {
    width: 22px;
    height: 22px;
    border-radius: 6px;
    background: linear-gradient(135deg, var(--accent) 0%, color-mix(in srgb, var(--accent) 70%, white) 100%);
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
}
.brand-arrow {
    color: var(--text-muted);
    font-weight: 400;
    padding: 0 0.15rem;
}

.container {
    flex: 1;
    width: 100%;
    max-width: 640px;
    margin: 0 auto;
    padding: 3rem 1.25rem 4rem;
}

.footer {
    text-align: center;
    padding: 1.25rem;
    font-size: 0.8125rem;
    color: var(--text-faint);
    border-top: 1px solid var(--border);
}

/* ── Hero ───────────────────────────────────────────────── */
.hero {
    text-align: center;
    margin-bottom: 2rem;
}
.hero h1 {
    font-size: 1.875rem;
    font-weight: 600;
    letter-spacing: -0.025em;
    margin-bottom: 0.5rem;
    line-height: 1.2;
}
.hero-sub {
    color: var(--text-muted);
    font-size: 0.9375rem;
}

/* ── Card ───────────────────────────────────────────────── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
}
.card + .card,
.card + #result .card,
#result .card { margin-top: 1.25rem; }
.card--narrow {
    max-width: 380px;
    margin: 5rem auto 0;
    padding: 2rem;
}
.card-title {
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    margin-bottom: 0.375rem;
}
.card-sub {
    color: var(--text-muted);
    font-size: 0.9375rem;
    margin-bottom: 1.5rem;
}

.stack > * + * { margin-top: 0.875rem; }

/* ── Form fields ────────────────────────────────────────── */
.field { display: block; }
.field-label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 0.375rem;
}
.field input,
input[type="password"] {
    width: 100%;
    padding: 0.625rem 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-xs);
    font: inherit;
    color: var(--text);
    transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus,
input[type="password"]:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ── Buttons ────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5625rem 1rem;
    font-size: 0.9375rem;
    font-weight: 500;
    border: 1px solid transparent;
    border-radius: var(--radius-xs);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, transform 0.05s;
    text-decoration: none;
    white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}
.btn--primary {
    background: var(--accent);
    color: var(--accent-fg);
}
.btn--primary:hover {
    background: var(--accent-hover);
    text-decoration: none;
}
.btn--secondary {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border-strong);
}
.btn--secondary:hover {
    background: var(--surface-2);
    text-decoration: none;
}
.btn--block { width: 100%; }
.btn--lg { padding: 0.75rem 1.25rem; font-size: 1rem; }

.btn-ghost {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.875rem;
    cursor: pointer;
    padding: 0.375rem 0.75rem;
    border-radius: var(--radius-xs);
    transition: background 0.15s, color 0.15s;
}
.btn-ghost:hover {
    background: var(--surface-2);
    color: var(--text);
}

.btn .btn-label-busy { display: none; align-items: center; gap: 0.5rem; }
.htmx-request .btn-label-idle { display: none; }
.htmx-request .btn-label-busy { display: inline-flex; }
.htmx-request .btn--primary { opacity: 0.85; cursor: progress; }

.copy-btn.copied {
    background: var(--success-soft);
    color: var(--success);
    border-color: color-mix(in srgb, var(--success) 30%, transparent);
}

/* ── Drop zone ──────────────────────────────────────────── */
.drop-zone {
    position: relative;
    border: 2px dashed var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface-2);
    padding: 2.5rem 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s, transform 0.1s;
    margin-bottom: 1rem;
}
.drop-zone:hover,
.drop-zone:focus-visible {
    border-color: var(--accent);
    background: var(--accent-soft);
    outline: none;
}
.drop-zone.dragover {
    border-color: var(--accent);
    background: var(--accent-soft);
    transform: scale(1.005);
}
.drop-zone.has-file {
    border-style: solid;
    border-color: var(--border-strong);
    padding: 1.25rem 1.5rem;
}
.drop-zone.has-file .drop-zone-inner { opacity: 0.55; }
.drop-zone input[type="file"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}
.drop-zone-inner {
    pointer-events: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    transition: opacity 0.2s;
}
.drop-icon {
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}
.drop-title {
    font-weight: 500;
    color: var(--text);
}
.drop-sub {
    font-size: 0.875rem;
    color: var(--text-muted);
}
.link {
    color: var(--accent);
    font-weight: 500;
}

/* ── File chip ──────────────────────────────────────────── */
.file-chip {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.625rem 0.75rem;
    margin-bottom: 1rem;
}
.file-chip-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
}
.file-chip-meta {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}
.file-chip-name {
    font-weight: 500;
    font-size: 0.9375rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.file-chip-size {
    font-size: 0.8125rem;
    color: var(--text-muted);
}
.file-chip-clear {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 1.25rem;
    line-height: 1;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-xs);
    transition: background 0.15s, color 0.15s;
}
.file-chip-clear:hover {
    background: var(--border);
    color: var(--text);
}

/* ── Spinner ────────────────────────────────────────────── */
.spinner {
    width: 14px;
    height: 14px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Supported formats ──────────────────────────────────── */
.supported {
    margin-top: 1rem;
    font-size: 0.8125rem;
    color: var(--text-muted);
}
.supported summary {
    cursor: pointer;
    padding: 0.375rem 0;
    user-select: none;
    color: var(--text-muted);
}
.supported summary:hover { color: var(--text); }
.supported p {
    margin-top: 0.5rem;
    padding: 0.625rem 0.75rem;
    background: var(--surface-2);
    border-radius: var(--radius-xs);
    line-height: 1.7;
}

/* ── Result ─────────────────────────────────────────────── */
.result-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}
.result-head-meta {
    display: flex;
    gap: 0.75rem;
    min-width: 0;
}
.result-icon {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--success-soft);
    color: var(--success);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
    margin-top: 0.125rem;
}
.result-filename {
    font-weight: 600;
    font-size: 1rem;
    word-break: break-all;
}
.result-info {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-top: 0.125rem;
}
.result-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}
.result-preview {
    border-top: 1px solid var(--border);
    padding-top: 1rem;
}
.result-preview summary {
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text-muted);
    padding: 0.25rem 0 0.5rem;
    user-select: none;
}
.result-preview summary:hover { color: var(--text); }
.preview {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.875rem;
    max-height: 380px;
    overflow-y: auto;
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    line-height: 1.55;
    white-space: pre-wrap;
    word-break: break-word;
    margin-top: 0.5rem;
}
.preview-truncated {
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-faint);
    font-style: italic;
}

/* ── Alerts ─────────────────────────────────────────────── */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-xs);
    font-size: 0.9375rem;
    margin-bottom: 1rem;
}
.alert--error {
    background: var(--error-soft);
    color: var(--error);
    border: 1px solid var(--error-border);
}

/* ── Multi-result stack ─────────────────────────────────── */
#results {
    margin-top: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
#results:empty { display: none; }

.result {
    position: relative;
    animation: result-in 0.2s ease-out;
}
@keyframes result-in {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.result--loading {
    padding: 1.25rem 1.5rem;
}
.loading-row {
    display: flex;
    align-items: center;
    gap: 0.875rem;
}
.spinner--lg {
    width: 20px;
    height: 20px;
    border-width: 2.5px;
    color: var(--accent);
    flex-shrink: 0;
}
.loading-meta { flex: 1; min-width: 0; }
.loading-name {
    font-weight: 500;
    font-size: 0.9375rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.loading-status {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-top: 0.125rem;
}

.result--error {
    padding: 1rem 1.25rem;
    padding-right: 2.5rem;
}
.result--error .alert { margin-bottom: 0; }

.result-remove {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.5rem;
    line-height: 1;
    padding: 0.25rem 0.625rem;
    border-radius: var(--radius-xs);
    transition: background 0.15s, color 0.15s;
}
.result-remove:hover {
    background: var(--surface-2);
    color: var(--text);
}

/* ── Bulk actions bar ───────────────────────────────────── */
.bulk-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 1rem;
    padding: 0.625rem 1rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    flex-wrap: wrap;
}
.bulk-count {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 500;
}
.bulk-actions-buttons {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* ── Claude paste code panel ────────────────────────────── */
.claude-code-panel {
    margin-bottom: 1rem;
    padding: 0.875rem 1rem;
    background: linear-gradient(135deg, var(--accent-soft), color-mix(in srgb, var(--accent-soft) 60%, transparent));
    border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
    border-radius: var(--radius-sm);
}
.claude-code-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}
.claude-code-meta {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}
.claude-code-label {
    font-weight: 600;
    font-size: 0.9375rem;
    color: var(--text);
}
.claude-code-help {
    font-size: 0.75rem;
    color: var(--text-muted);
}
.claude-code-value,
.claude-link-value {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.875rem;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-xs);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    max-width: 100%;
    min-width: 0;
}
.claude-code-value:hover,
.claude-link-value:hover {
    border-color: var(--accent);
}
.claude-code-text {
    font-family: var(--font-mono);
    font-size: 1.0625rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    color: var(--accent);
}
.claude-link-text {
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--accent);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}
.claude-link-value {
    flex: 1 1 100%;
    min-width: 0;
    margin-top: 0.5rem;
}
.claude-link-value--small {
    margin-top: 0.25rem;
    margin-bottom: 0.5rem;
    padding: 0.375rem 0.625rem;
}
.claude-link-value--small .claude-link-text {
    font-size: 0.75rem;
}
.claude-link-value.copied,
.claude-code-value.copied {
    border-color: var(--success);
}
.claude-code-advanced {
    margin-top: 0.75rem;
    font-size: 0.8125rem;
    color: var(--text-muted);
}
.claude-code-advanced summary {
    cursor: pointer;
    padding: 0.25rem 0;
    user-select: none;
}
.claude-code-advanced summary:hover { color: var(--text); }
.claude-code-advanced summary code {
    font-family: var(--font-mono);
    background: var(--accent-soft);
    color: var(--accent);
    padding: 0.0625rem 0.375rem;
    border-radius: 4px;
    letter-spacing: 0.06em;
    font-weight: 600;
}
.claude-code-advanced p {
    margin-top: 0.375rem;
    padding-left: 0.875rem;
    border-left: 2px solid var(--border);
    color: var(--text-muted);
    line-height: 1.55;
}
.claude-code-advanced p code {
    font-family: var(--font-mono);
    background: var(--surface-2);
    padding: 0.0625rem 0.25rem;
    border-radius: 3px;
    font-size: 0.875em;
}
.claude-code-advanced p em strong {
    font-family: var(--font-mono);
    color: var(--accent);
}
.claude-code-copied-hint {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--success-soft);
    color: var(--success);
    font-weight: 600;
    border-radius: var(--radius-xs);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s;
}
.claude-code-value.copied .claude-code-copied-hint { opacity: 1; }
.claude-code-prompt {
    margin-top: 0.625rem;
    font-size: 0.8125rem;
    color: var(--text-muted);
    line-height: 1.5;
}
.claude-code-prompt em {
    font-style: normal;
    color: var(--text);
}
.claude-code-prompt strong {
    font-family: var(--font-mono);
    color: var(--accent);
    letter-spacing: 0.08em;
}

/* ── Connector panel ────────────────────────────────────── */
.connector {
    margin-top: 1.25rem;
    padding: 0;
    overflow: hidden;
}
.connector > summary {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 1.25rem;
    cursor: pointer;
    list-style: none;
    user-select: none;
    background: var(--surface);
}
.connector > summary::-webkit-details-marker { display: none; }
.connector-icon { font-size: 1.125rem; }
.connector-title {
    flex: 1;
    font-weight: 500;
}
.connector-chev {
    color: var(--text-muted);
    transition: transform 0.15s;
}
.connector[open] .connector-chev { transform: rotate(180deg); }
.connector-body {
    padding: 0 1.25rem 1.25rem;
    border-top: 1px solid var(--border);
    padding-top: 1rem;
}
.connector-lead {
    color: var(--text-muted);
    font-size: 0.9375rem;
    margin-bottom: 0.875rem;
}
.connector-url-row {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}
.connector-url-row input {
    flex: 1;
    min-width: 0;
    padding: 0.5rem 0.625rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    color: var(--text);
}
.connector-steps {
    padding-left: 1.25rem;
    margin-bottom: 0.875rem;
    color: var(--text);
    font-size: 0.9375rem;
}
.connector-steps li { margin-bottom: 0.375rem; }
.connector-steps em {
    font-style: normal;
    color: var(--text-muted);
}
.connector-warn {
    font-size: 0.8125rem;
    color: var(--text-muted);
    padding: 0.5rem 0.75rem;
    background: var(--accent-soft);
    border-radius: var(--radius-xs);
}

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 480px) {
    .container { padding: 2rem 1rem 3rem; }
    .hero h1 { font-size: 1.5rem; }
    .card { padding: 1.25rem; }
    .card--narrow { margin-top: 2.5rem; padding: 1.5rem; }
    .drop-zone { padding: 2rem 1rem; }
    .topbar { padding: 0.75rem 1rem; }
}
