@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,500;9..144,600&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
    --bg: #f6f3ec;
    --bg-texture: #efe9db;
    --card: #fffdf9;
    --ink: #1c2333;
    --muted: #6d6a60;
    --primary: #1f3a5f;
    --primary-dark: #142944;
    --accent: #b8863f;
    --accent-soft: #e9dcc0;
    --border: #e3ddcc;
    --error-bg: #fbeeec;
    --error-text: #a13f2e;
    --success-bg: #eef4ec;
    --success-text: #34572f;

    --font-display: 'Fraunces', Georgia, serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font-body);
    background:
        radial-gradient(circle at 1px 1px, rgba(28, 35, 51, 0.05) 1px, transparent 0) 0 0 / 22px 22px,
        var(--bg);
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
}

.wrap {
    max-width: 620px;
    margin: 0 auto;
    padding: 56px 20px 40px;
}

/* ---------- Header ---------- */

.app-header {
    text-align: center;
    margin-bottom: 36px;
}

.app-header .eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--accent);
    background: var(--accent-soft);
    border: 1px solid rgba(184, 134, 63, 0.35);
    border-radius: 999px;
    padding: 5px 14px;
    margin-bottom: 18px;
}

.app-header .eyebrow::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
    display: inline-block;
}

.app-header h1 {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 34px;
    letter-spacing: -0.01em;
    margin: 0 0 8px;
    color: var(--primary);
}

.app-header p {
    color: var(--muted);
    font-size: 15px;
    margin: 0;
}

/* ---------- Card ---------- */

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 36px 36px 32px;
    position: relative;
    box-shadow: 0 1px 2px rgba(28, 35, 51, 0.04), 0 12px 32px -16px rgba(28, 35, 51, 0.18);
}

/* perforated top edge, like a tear-off document */
.card::before {
    content: "";
    position: absolute;
    top: -1px;
    left: 24px;
    right: 24px;
    height: 1px;
    background-image: repeating-linear-gradient(to right, var(--border) 0 6px, transparent 6px 12px);
}

.card h2 {
    font-family: var(--font-display);
    font-weight: 600;
    margin: 0 0 10px;
    font-size: 21px;
    color: var(--ink);
}

.muted {
    color: var(--muted);
    font-size: 14px;
    line-height: 1.65;
}

code {
    font-family: var(--font-mono);
    background: var(--accent-soft);
    color: var(--primary-dark);
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 12.5px;
}

/* ---------- Upload form / dropzone ---------- */

.upload-form {
    margin-top: 24px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.file-label {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    text-align: center;
    padding: 34px 20px;
    border: 1.5px dashed var(--border);
    border-radius: 6px;
    background: #fbf9f4;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.file-label:hover,
.file-label.is-dragover {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.file-label .drop-icon {
    width: 34px;
    height: 34px;
    color: var(--accent);
}

.file-label .drop-text {
    font-size: 14px;
    color: var(--ink);
    font-weight: 500;
}

.file-label .drop-hint {
    font-family: var(--font-mono);
    font-size: 11.5px;
    color: var(--muted);
    letter-spacing: 0.02em;
}

.file-label .file-chosen {
    font-family: var(--font-mono);
    font-size: 12.5px;
    color: var(--primary);
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 4px 10px;
    display: none;
}

.file-label.has-file .file-chosen {
    display: inline-block;
}

.file-label.has-file .drop-text,
.file-label.has-file .drop-hint {
    display: none;
}

.file-label input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 13px 22px;
    border-radius: 6px;
    font-family: var(--font-body);
    font-size: 14.5px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: background 0.15s ease, transform 0.1s ease;
}

.btn:hover {
    background: var(--primary-dark);
}

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

.btn:focus-visible,
.file-label input[type="file"]:focus-visible + * {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ---------- Alerts ---------- */

.alert {
    padding: 13px 16px;
    border-radius: 6px;
    font-size: 13.5px;
    margin-bottom: 20px;
    border: 1px solid transparent;
}

.alert-error {
    background: var(--error-bg);
    color: var(--error-text);
    border-color: rgba(161, 63, 46, 0.2);
}

.alert-success {
    background: var(--success-bg);
    color: var(--success-text);
    border-color: rgba(52, 87, 47, 0.2);
}

/* ---------- Result page: stamp ---------- */

.stamp {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    width: 92px;
    height: 92px;
    border: 2px solid var(--accent);
    border-radius: 50%;
    color: var(--accent);
    transform: rotate(-8deg);
    margin-bottom: 18px;
    font-family: var(--font-mono);
}

.stamp::before {
    content: "";
    position: absolute;
    width: 78px;
    height: 78px;
    border: 1px dashed var(--accent);
    border-radius: 50%;
}

.stamp svg {
    width: 26px;
    height: 26px;
    margin-bottom: 2px;
}

.stamp span {
    font-size: 8.5px;
    letter-spacing: 0.1em;
    font-weight: 600;
}

.result-meta {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin: 0 0 22px;
}

.result-meta .count {
    font-family: var(--font-display);
    font-size: 30px;
    font-weight: 600;
    color: var(--primary);
}

.file-pill {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: #fbf9f4;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 12px 16px;
    margin-bottom: 22px;
}

.file-pill .name {
    font-family: var(--font-mono);
    font-size: 12.5px;
    color: var(--ink);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
    text-decoration: none;
    font-size: 13.5px;
    margin-top: 22px;
}

.back-link:hover {
    color: var(--primary);
}

/* ---------- Footer ---------- */

.app-footer {
    margin-top: 36px;
    text-align: center;
    color: var(--muted);
    font-size: 11.5px;
    font-family: var(--font-mono);
    letter-spacing: 0.03em;
}

@media (max-width: 480px) {
    .wrap { padding: 40px 16px 32px; }
    .card { padding: 26px 22px 24px; }
    .app-header h1 { font-size: 27px; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
}
