@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,300;0,400;0,500;1,300;1,400&family=DM+Sans:opsz,wght@9..40,300;9..40,400;9..40,500&family=JetBrains+Mono:wght@400;500&display=swap');

/* ─── Tokens ─────────────────────────────────────────────────────────────── */
:root {
    --bg:           #0b0a08;
    --bg-card:      #111009;
    --bg-hover:     #17160e;
    --border:       #222018;
    --border-mid:   #2c2a20;
    --text:         #eee9dc;
    --text-2:       #7c7868;
    --text-3:       #3a3830;
    --accent:       #c4853a;
    --accent-faint: rgba(196, 133, 58, 0.07);
    --accent-mid:   rgba(196, 133, 58, 0.25);
    --error-text:   #d96b5a;
    --error-bg:     rgba(217, 107, 90, 0.07);
    --error-border: rgba(217, 107, 90, 0.18);
    --radius:       3px;
    --f-display:    'Cormorant Garamond', Georgia, serif;
    --f-body:       'DM Sans', system-ui, sans-serif;
    --f-mono:       'JetBrains Mono', 'Courier New', monospace;
}

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

html { background: var(--bg); }

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

/* ─── Noise overlay ──────────────────────────────────────────────────────── */
.noise {
    position: fixed;
    inset: 0;
    z-index: 900;
    pointer-events: none;
    opacity: 0.028;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)'/%3E%3C/svg%3E");
    background-size: 300px 300px;
}

/* Subtle grid texture */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(196, 133, 58, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(196, 133, 58, 0.035) 1px, transparent 1px);
    background-size: 72px 72px;
    z-index: 0;
}

/* ─── Page ───────────────────────────────────────────────────────────────── */
.page {
    position: relative;
    z-index: 1;
    max-width: 980px;
    margin: 0 auto;
    padding: clamp(40px, 8vw, 80px) clamp(16px, 4vw, 32px) 80px;
}

/* ─── Header ─────────────────────────────────────────────────────────────── */
.header {
    margin-bottom: 48px;
    animation: rise 0.7s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.header-inner {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
}

.wordmark {
    font-family: var(--f-display);
    font-size: clamp(2rem, 5.5vw, 3.8rem);
    font-weight: 300;
    letter-spacing: -0.025em;
    line-height: 1;
    color: var(--text);
}

.wordmark em {
    font-style: italic;
    color: var(--accent);
}

.header-sub {
    font-family: var(--f-mono);
    font-size: 0.68rem;
    color: var(--text-3);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    align-self: flex-end;
    padding-bottom: 5px;
}

.header-rule {
    height: 1px;
    background: linear-gradient(90deg, var(--border-mid) 0%, transparent 70%);
}

/* ─── Alert ──────────────────────────────────────────────────────────────── */
.alert {
    display: flex;
    gap: 10px;
    align-items: baseline;
    margin-top: 18px;
    padding: 12px 16px;
    background: var(--error-bg);
    border: 1px solid var(--error-border);
    border-radius: var(--radius);
    font-size: 0.82rem;
    color: var(--error-text);
    line-height: 1.6;
}

.alert-label {
    font-family: var(--f-mono);
    font-size: 0.65rem;
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--error-text);
    flex-shrink: 0;
    opacity: 0.7;
}

/* ─── Panel (unified container) ─────────────────────────────────────────── */
.panel {
    border: 1px solid var(--border-mid);
    border-radius: 4px;
    overflow: hidden;
    animation: rise 0.7s 0.1s cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* ─── Tools grid ─────────────────────────────────────────────────────────── */
.tools-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
}

@media (max-width: 660px) {
    .tools-grid { grid-template-columns: 1fr; }
}

/* ─── Tool card ──────────────────────────────────────────────────────────── */
.tool-card {
    background: var(--bg-card);
    padding: clamp(24px, 4vw, 40px) clamp(20px, 3.5vw, 36px);
    transition: background 0.25s;
    border-right: 1px solid var(--border);
}

.tool-card--right {
    border-right: none;
}

@media (max-width: 660px) {
    .tool-card { border-right: none; border-bottom: 1px solid var(--border); }
    .tool-card--right { border-bottom: none; }
}

.tool-card:hover {
    background: var(--bg-hover);
}

/* ─── Tool header ────────────────────────────────────────────────────────── */
.tool-header {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    margin-bottom: 24px;
}

.tool-num {
    font-family: var(--f-display);
    font-size: 3.2rem;
    font-weight: 300;
    line-height: 0.9;
    color: var(--accent);
    opacity: 0.55;
    letter-spacing: -0.04em;
    flex-shrink: 0;
    user-select: none;
}

.tool-title {
    font-family: var(--f-display);
    font-size: 1.45rem;
    font-weight: 400;
    letter-spacing: 0.01em;
    line-height: 1.15;
    color: var(--text);
    margin-bottom: 7px;
}

.tool-desc {
    font-size: 0.78rem;
    font-weight: 300;
    color: var(--text-2);
    line-height: 1.65;
}

/* ─── Upload zone ────────────────────────────────────────────────────────── */
.upload-zone {
    position: relative;
    margin-bottom: 14px;
}

.upload-zone input[type="file"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    z-index: 2;
}

.upload-zone label {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 26px 20px;
    border: 1px dashed var(--border-mid);
    border-radius: var(--radius);
    cursor: pointer;
    text-align: center;
    transition: border-color 0.2s, background 0.2s;
    min-height: 110px;
}

.upload-zone:hover label,
.upload-zone input:focus-visible + label {
    border-color: var(--accent-mid);
    background: var(--accent-faint);
}

.upload-zone.has-file label {
    border-style: solid;
    border-color: var(--accent-mid);
    background: var(--accent-faint);
}

.upload-icon {
    width: 18px;
    height: 18px;
    color: var(--text-3);
    transition: color 0.2s;
    flex-shrink: 0;
}

.upload-zone:hover .upload-icon,
.upload-zone.has-file .upload-icon {
    color: var(--accent);
}

.upload-cta {
    font-size: 0.76rem;
    color: var(--text-2);
    font-weight: 300;
    letter-spacing: 0.02em;
    transition: color 0.2s;
}

.upload-zone:hover .upload-cta {
    color: var(--text);
}

.upload-name {
    font-family: var(--f-mono);
    font-size: 0.68rem;
    color: var(--accent);
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-height: 1em;
}

/* ─── Page range ─────────────────────────────────────────────────────────── */
.page-range {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    margin-bottom: 14px;
}

.range-field {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.range-field label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-2);
    font-weight: 500;
}

.range-field input[type="number"] {
    width: 100%;
    padding: 8px 10px;
    background: transparent;
    border: 1px solid var(--border-mid);
    border-radius: var(--radius);
    color: var(--text);
    font-family: var(--f-mono);
    font-size: 0.8rem;
    appearance: textfield;
    -moz-appearance: textfield;
    transition: border-color 0.2s, background 0.2s;
}

.range-field input[type="number"]::-webkit-outer-spin-button,
.range-field input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
}

.range-field input[type="number"]:focus {
    outline: none;
    border-color: var(--accent-mid);
    background: var(--accent-faint);
}

.range-field input[type="number"]::placeholder {
    color: var(--text-3);
}

.range-dash {
    font-family: var(--f-display);
    font-size: 1.1rem;
    font-weight: 300;
    color: var(--text-3);
    padding-bottom: 8px;
    flex-shrink: 0;
    user-select: none;
}

/* ─── Tool footer ────────────────────────────────────────────────────────── */
.tool-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

.output-pill {
    font-family: var(--f-mono);
    font-size: 0.65rem;
    color: var(--text-3);
    letter-spacing: 0.04em;
}

/* ─── Button ─────────────────────────────────────────────────────────────── */
.btn {
    padding: 8px 20px;
    background: transparent;
    color: var(--accent);
    border: 1px solid rgba(196, 133, 58, 0.35);
    border-radius: var(--radius);
    font-family: var(--f-body);
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.18s, color 0.18s, border-color 0.18s;
}

.btn:hover {
    background: var(--accent);
    color: var(--bg);
    border-color: var(--accent);
}

.btn:active {
    opacity: 0.85;
}

/* ─── Notes ──────────────────────────────────────────────────────────────── */
.notes {
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    padding: 20px clamp(20px, 3.5vw, 36px);
    display: flex;
    gap: 24px;
    align-items: baseline;
    flex-wrap: wrap;
}

.notes-label {
    font-family: var(--f-mono);
    font-size: 0.62rem;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--text-3);
    font-weight: 500;
    flex-shrink: 0;
    padding-top: 1px;
}

.notes-list {
    list-style: none;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 200px;
}

.notes-list li {
    font-size: 0.75rem;
    font-weight: 300;
    color: var(--text-2);
    line-height: 1.6;
    padding-left: 12px;
    position: relative;
}

.notes-list li::before {
    content: '·';
    position: absolute;
    left: 0;
    color: var(--accent);
    opacity: 0.45;
}

.notes-list code {
    font-family: var(--f-mono);
    font-size: 0.7rem;
    color: var(--text);
    background: rgba(255, 255, 255, 0.04);
    padding: 1px 5px;
    border-radius: 2px;
    letter-spacing: 0.02em;
}

/* ─── Animation ──────────────────────────────────────────────────────────── */
@keyframes rise {
    from {
        opacity: 0;
        transform: translateY(18px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ─── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
    .notes {
        flex-direction: column;
        gap: 12px;
    }

    .tool-footer {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .btn { width: 100%; text-align: center; }
}
