:root {
    --ink: #0a0a0a;
    --paper: #f5f0e8;
    --accent: #bc6c25;
    --accent2: #1a6bff;
    --muted: #6c757d;
    --border: 2px solid var(--ink);
}

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

body {
    font-family: 'Space Mono', monospace;
    background: var(--paper);
    color: var(--ink);
    min-height: 100vh;
    overflow-x: hidden;
    cursor: crosshair;
}

/* Noise texture overlay */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.04'/%3E%3C/svg%3E");
    pointer-events: none;
    z-index: 100;
    opacity: 0.6;
}

header {
    border-bottom: var(--border);
    padding: 20px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

.logo {
    font-family: 'Black Han Sans', sans-serif;
    font-size: clamp(1.4rem, 3vw, 2rem);
    letter-spacing: 0.15em;
    position: relative;
}

.logo span {
    color: var(--accent);
}

.tagline {
    font-size: 0.65rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--muted);
}

.counter-badge {
    font-size: 0.7rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--muted);
    text-align: right;
}

.counter-badge strong {
    display: block;
    font-size: 1.6rem;
    color: var(--ink);
    line-height: 1;
    font-family: 'Black Han Sans', sans-serif;
}

/* Main stage */
main {
    max-width: 960px;
    margin: 0 auto;
    padding: 60px 40px 40px;
}

/* Category selector */
.categories {
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    margin-bottom: 40px;
    border: var(--border);
}

.cat-group {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 140px;
}

.cat-group-header {
    font-family: 'Space Mono', monospace;
    font-size: 0.7rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    padding: 10px 16px;
    background: transparent;
    cursor: pointer;
    transition: all 0.12s;
    color: var(--ink);
    border: none;
    border-bottom: var(--border);
    text-align: left;
    width: 100%;
}

.cat-group-header:hover {
    background: var(--ink);
    color: var(--paper);
}

.cat-group-header.active {
    background: var(--ink);
    color: var(--paper);
}

.cat-group-people {
    display: flex;
    flex-direction: column;
}

.person-btn {
    font-family: 'Space Mono', monospace;
    font-size: 0.65rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    padding: 8px 16px;
    background: transparent;
    cursor: pointer;
    transition: all 0.1s;
    color: var(--muted);
    border: none;
    border-bottom: 1px solid #e8e4dc;
    text-align: left;
    width: 100%;
}

.person-btn:last-child {
    border-bottom: none;
}

.person-btn:hover {
    background: #f0ebe0;
    color: var(--ink);
}

.person-btn.active {
    background: var(--ink);
    color: var(--paper);
    font-weight: bold;
}

/* Caption display */
.caption-stage {
    border: var(--border);
    min-height: 240px;
    padding: 48px 52px;
    position: relative;
    background: #fff;
    margin-bottom: 24px;
    overflow: hidden;
}

.caption-stage::before {
    content: attr(data-number);
    position: absolute;
    top: 16px;
    right: 20px;
    font-size: 0.65rem;
    letter-spacing: 0.2em;
    color: var(--muted);
    text-transform: uppercase;
}

.caption-label {
    font-size: 0.6rem;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.caption-label::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--accent);
    opacity: 0.3;
}

.caption-text {
    font-family: 'Black Han Sans', sans-serif;
    font-size: clamp(1.6rem, 4vw, 2.8rem);
    line-height: 1.2;
    letter-spacing: 0.02em;
    transition: opacity 0.2s;
}

.caption-text.flash {
    opacity: 0;
}

.caption-meta {
    margin-top: 24px;
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.meta-tag {
    font-size: 0.6rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    padding: 4px 10px;
    border: 1px solid var(--ink);
    color: var(--muted);
}

/* Action buttons */
.actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 48px;
}

.btn-generate {
    font-family: 'Black Han Sans', sans-serif;
    font-size: 1.05rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    padding: 18px 40px;
    background: var(--ink);
    color: var(--paper);
    border: var(--border);
    cursor: pointer;
    position: relative;
    top: 0; left: 0;
    transition: all 0.1s;
    flex: 1;
    min-width: 200px;
}

.btn-generate:hover {
    background: var(--accent);
    top: -3px;
    left: -3px;
    box-shadow: 3px 3px 0 var(--ink);
}

.btn-generate:active {
    top: 0; left: 0;
    box-shadow: none;
}

.btn-copy, .btn-shuffle {
    font-family: 'Space Mono', monospace;
    font-size: 0.7rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    padding: 18px 24px;
    background: transparent;
    color: var(--ink);
    border: var(--border);
    cursor: pointer;
    transition: all 0.1s;
    position: relative;
    top: 0; left: 0;
    white-space: nowrap;
}

.btn-copy:hover, .btn-shuffle:hover {
    top: -2px; left: -2px;
    box-shadow: 2px 2px #0a0a0a;
    background: #bc6c25;
    color: #fff;
    border-color: #0a0a0a;
}

.btn-copy.copied {
    background: #2ecc71;
    color: white;
    border-color: #2ecc71;
}

/* History */
.history-section {
    border-top: var(--border);
    padding-top: 32px;
}

.section-title {
    font-size: 0.65rem;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.section-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: currentColor;
    opacity: 0.3;
}

.history-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 12px;
}

.history-item {
    border: 1px solid #ddd;
    padding: 16px 18px;
    font-size: 0.82rem;
    line-height: 1.5;
    cursor: pointer;
    transition: all 0.1s;
    position: relative;
    background: #fff;
}

.history-item:hover {
    border-color: var(--ink);
    box-shadow: 2px 2px 0 var(--ink);
    transform: translate(-2px, -2px);
}

.history-item .h-cat {
    font-size: 0.55rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 6px;
}

/* Spin animation */
@keyframes spin {
    from { transform: rotate(0); }
    to { transform: rotate(360deg); }
}

.spinning { animation: spin 0.4s linear; }

/* Tooltip */
.tooltip {
    position: fixed;
    background: var(--ink);
    color: var(--paper);
    font-family: 'Space Mono', monospace;
    font-size: 0.6rem;
    letter-spacing: 0.1em;
    padding: 6px 12px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 200;
}

.tooltip.show { opacity: 1; }

/* Hashtag box */
.hashtag-box {
    border: var(--border);
    padding: 16px 24px;
    background: #fff;
    margin-bottom: 24px;
    display: none;
}

.hashtag-box-label {
    font-size: 0.6rem;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 8px;
}

.hashtag-line {
    font-size: 0.82rem;
    color: var(--accent2);
    letter-spacing: 0.05em;
    font-style: italic;
}

/* Keyword box */
  .keyword-box {
    border: 2px solid #6c757d;
    padding: 16px 24px;
    background: #fffdf5;
    margin-bottom: 24px;
}

.keyword-line {
    font-family: 'Space Mono', monospace;
    font-size: 0.7rem;
    color: #1a6bff;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-top: 6px;
}

footer {
    border-top: var(--border);
    padding: 20px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.6rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--muted);
    margin-top: 40px;
}

@media (max-width: 600px) {
    header, main, footer { padding-left: 20px; padding-right: 20px; }
    .caption-stage { padding: 32px 28px; }
}