@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@600;700;800&family=IBM+Plex+Sans:wght@300;400;500;600&family=IBM+Plex+Mono:wght@400;500&display=swap');

:root {
    --bg: #faf8f4;
    --panel: #ffffff;
    --ink: #1a1a1a;
    --muted: #6b6b6b;
    --accent: #d4522f;
    --accent-2: #2563a8;
    --accent-light: #f4e8e3;
    --accent-2-light: #e8f1fb;
    --border: rgba(26, 26, 26, 0.08);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.12);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--ink);
    min-height: 100vh;
    position: relative;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Sophisticated background decoration */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 400px;
    background: linear-gradient(135deg, #fff5ed 0%, #faf8f4 50%, #f0f4fa 100%);
    opacity: 0.6;
    z-index: 0;
    pointer-events: none;
}

body::after {
    content: '';
    position: fixed;
    bottom: -200px;
    right: -200px;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(37, 99, 168, 0.05) 0%, transparent 70%);
    border-radius: 50%;
    z-index: 0;
    pointer-events: none;
}

.container {
    width: min(1200px, 94%);
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

/* Header with refined styling */
.site-header {
    padding: 32px 0;
    border-bottom: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 100;
    transition: var(--transition);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.logo {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 28px;
    font-weight: 700;
    color: var(--ink);
    text-decoration: none;
    letter-spacing: -0.02em;
    transition: var(--transition);
}

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

.nav {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.nav a {
    text-decoration: none;
    color: var(--ink);
    font-weight: 500;
    font-size: 15px;
    padding: 10px 18px;
    border-radius: var(--radius-lg);
    transition: var(--transition);
    position: relative;
}

.nav a:hover {
    background: var(--accent-light);
    color: var(--accent);
    transform: translateY(-1px);
}

.nav .ghost {
    border: 1.5px solid var(--border);
    background: var(--panel);
}

.nav .ghost:hover {
    border-color: var(--accent);
    background: var(--accent);
    color: white;
}

.user-pill {
    background: var(--accent-2-light);
    color: var(--accent-2);
    padding: 10px 18px;
    border-radius: var(--radius-lg);
    font-size: 14px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.user-pill::before {
    content: '●';
    font-size: 8px;
}

/* Main content */
.main-content {
    padding: 48px 0 80px;
}

/* Hero section with improved layout */
.hero {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 48px;
    align-items: start;
    margin-bottom: 56px;
}

.hero > div:first-child {
    padding-top: 16px;
}

.hero h1 {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: clamp(36px, 5vw, 56px);
    font-weight: 800;
    margin: 0 0 16px;
    line-height: 1.1;
    letter-spacing: -0.03em;
    color: var(--ink);
}

.hero p {
    color: var(--muted);
    margin: 0;
    font-size: 18px;
    max-width: 500px;
}

.hero-card {
    background: var(--panel);
    padding: 32px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    position: relative;
    overflow: hidden;
}

.hero-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--accent) 0%, var(--accent-2) 100%);
}

.hero-card h3 {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 20px;
    font-weight: 700;
    margin: 0 0 24px;
    color: var(--ink);
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.stat {
    background: linear-gradient(135deg, #fafafa 0%, #f5f5f5 100%);
    padding: 20px;
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    gap: 8px;
    border: 1px solid var(--border);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.stat::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 3px;
    height: 100%;
    background: var(--accent);
    opacity: 0;
    transition: var(--transition);
}

.stat:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat:hover::before {
    opacity: 1;
}

.stat-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--muted);
    font-weight: 600;
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    font-family: 'IBM Plex Mono', monospace;
    color: var(--ink);
    line-height: 1;
}

/* Panel styling */
.panel {
    background: var(--panel);
    padding: 40px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    margin-bottom: 32px;
    border: 1px solid var(--border);
    animation: fadeInUp 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.panel.narrow {
    max-width: 500px;
    margin: 0 auto;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 32px;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--border);
}

.panel-header h2 {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 28px;
    font-weight: 700;
    margin: 0;
    color: var(--ink);
}

/* Tag grid for POS tags */
.tag-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 16px;
}

.tag-card {
    background: linear-gradient(135deg, #fafafa 0%, #f5f5f5 100%);
    padding: 20px;
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    gap: 10px;
    border: 1px solid var(--border);
    transition: var(--transition);
    cursor: default;
    position: relative;
    overflow: hidden;
}

.tag-card::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent) 0%, var(--accent-2) 100%);
    opacity: 0;
    transition: var(--transition);
}

.tag-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--accent);
}

.tag-card:hover::after {
    opacity: 1;
}

.tag-name {
    font-weight: 600;
    font-size: 16px;
    color: var(--ink);
    font-family: 'IBM Plex Mono', monospace;
}

.tag-count {
    color: var(--accent);
    font-size: 24px;
    font-weight: 700;
    font-family: 'IBM Plex Mono', monospace;
}

/* Forms */
.search-form,
.login-form,
.import-form {
    display: grid;
    gap: 16px;
}

.search-form {
    grid-template-columns: 1fr auto;
    max-width: 800px;
}

input[type="text"],
input[type="password"],
input[type="file"] {
    width: 100%;
    padding: 14px 18px;
    border-radius: var(--radius-md);
    border: 1.5px solid var(--border);
    font-family: inherit;
    font-size: 15px;
    background: var(--panel);
    transition: var(--transition);
    color: var(--ink);
}

input[type="text"]:focus,
input[type="password"]:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(212, 82, 47, 0.1);
}

input[type="file"] {
    padding: 12px 18px;
    cursor: pointer;
}

button {
    padding: 14px 32px;
    border-radius: var(--radius-md);
    border: none;
    background: var(--accent);
    color: white;
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 24px rgba(212, 82, 47, 0.25);
    background: #c24827;
}

button:active {
    transform: translateY(0);
}

/* Result list */
.result-list {
    display: grid;
    gap: 12px;
    margin-top: 24px;
}

.result-item {
    background: var(--panel);
    padding: 20px 24px;
    border-radius: var(--radius-md);
    text-decoration: none;
    color: inherit;
    display: grid;
    gap: 8px;
    transition: var(--transition);
    border: 1px solid var(--border);
    position: relative;
}

.result-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--accent);
    opacity: 0;
    transition: var(--transition);
    border-radius: var(--radius-md) 0 0 var(--radius-md);
}

.result-item:hover {
    transform: translateX(4px);
    box-shadow: var(--shadow-md);
    border-color: var(--accent);
}

.result-item:hover::before {
    opacity: 1;
}

.result-id {
    font-size: 13px;
    color: var(--muted);
    font-weight: 500;
    font-family: 'IBM Plex Mono', monospace;
}

.result-text {
    font-weight: 400;
    font-size: 16px;
    line-height: 1.6;
}

/* Token display */
.token-flow {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-start;
}

.token-card {
    background: linear-gradient(135deg, #fafafa 0%, #f5f5f5 100%);
    border-radius: var(--radius-md);
    padding: 14px 20px;
    min-width: 90px;
    text-align: center;
    border: 1px solid var(--border);
    transition: var(--transition);
    animation: tokenFadeIn 0.4s cubic-bezier(0.4, 0, 0.2, 1) backwards;
}

@keyframes tokenFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.token-card:nth-child(1) { animation-delay: 0.05s; }
.token-card:nth-child(2) { animation-delay: 0.1s; }
.token-card:nth-child(3) { animation-delay: 0.15s; }
.token-card:nth-child(4) { animation-delay: 0.2s; }
.token-card:nth-child(5) { animation-delay: 0.25s; }
.token-card:nth-child(6) { animation-delay: 0.3s; }
.token-card:nth-child(7) { animation-delay: 0.35s; }
.token-card:nth-child(8) { animation-delay: 0.4s; }

.token-card:hover {
    transform: translateY(-4px) scale(1.05);
    box-shadow: var(--shadow-md);
    border-color: var(--accent-2);
}

.token-word {
    font-weight: 600;
    font-size: 16px;
    color: var(--ink);
}

.token-tag {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--accent-2);
    margin-top: 6px;
    font-weight: 600;
    font-family: 'IBM Plex Mono', monospace;
}
.token-tag span {
    text-transform: none;
}

/* Form styling */
.form-row {
    display: grid;
    gap: 8px;
}

.form-row label {
    font-weight: 600;
    font-size: 14px;
    color: var(--ink);
}

.muted {
    color: var(--muted);
    font-size: 15px;
}

/* Messages */
.messages {
    display: grid;
    gap: 12px;
    margin-bottom: 32px;
}

.message {
    padding: 16px 20px;
    border-radius: var(--radius-md);
    background: var(--accent-2-light);
    color: var(--accent-2);
    border-left: 4px solid var(--accent-2);
    font-weight: 500;
    animation: slideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.message.success {
    background: #e8f5e9;
    color: #2e7d32;
    border-left-color: #2e7d32;
}

.message.error {
    background: #ffebee;
    color: #c62828;
    border-left-color: #c62828;
}

/* Footer */
.site-footer {
    padding: 40px 0;
    color: var(--muted);
    border-top: 1px solid var(--border);
    text-align: center;
    font-size: 14px;
}

/* Responsive design */
@media (max-width: 900px) {
    .hero {
        grid-template-columns: 1fr;
        gap: 32px;
    }

    .hero-card {
        order: -1;
    }

    .stat-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 720px) {
    .container {
        width: 90%;
    }

    .site-header {
        padding: 20px 0;
    }

    .header-inner {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .nav {
        width: 100%;
        justify-content: flex-start;
    }

    .logo {
        font-size: 24px;
    }

    .hero h1 {
        font-size: 32px;
    }

    .hero p {
        font-size: 16px;
    }

    .panel {
        padding: 24px;
    }

    .panel-header h2 {
        font-size: 22px;
    }

    .search-form {
        grid-template-columns: 1fr;
    }

    .tag-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }

    .stat-grid {
        grid-template-columns: 1fr;
    }

    .main-content {
        padding: 32px 0 60px;
    }
}

@media (max-width: 480px) {
    .hero-card h3 {
        font-size: 18px;
    }

    .stat-value {
        font-size: 24px;
    }

    .tag-grid {
        grid-template-columns: 1fr;
    }

    .token-flow {
        gap: 8px;
    }

    .token-card {
        min-width: 70px;
        padding: 10px 14px;
    }
}

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

/* Print styles */
@media print {
    .site-header,
    .site-footer,
    .nav,
    button {
        display: none;
    }

    body {
        background: white;
    }

    .panel {
        box-shadow: none;
        border: 1px solid #ddd;
        page-break-inside: avoid;
    }
}
