/* ============================================
   CSS Variables & Reset
   ============================================ */
:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #e0e7ff;
    --secondary: #10b981;
    --secondary-light: #d1fae5;
    --warning: #f59e0b;
    --danger: #ef4444;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --white: #ffffff;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius: 8px;
    --radius-lg: 12px;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: var(--gray-800);
    background: var(--gray-50);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ============================================
   Layout
   ============================================ */
.container {
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 20px;
}

.main {
    flex: 1;
    padding: 20px 0 60px;
}

/* ============================================
   Header
   ============================================ */
.header {
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    padding: 16px 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--gray-900);
    text-decoration: none;
}

.nav {
    display: flex;
    gap: 24px;
}

.nav a {
    color: var(--gray-600);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: color 0.2s;
}

.nav a:hover {
    color: var(--primary);
}

/* ============================================
   Hero
   ============================================ */
.hero {
    text-align: center;
    padding: 40px 0 30px;
}

.hero h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 12px;
    line-height: 1.2;
}

.hero-subtitle {
    font-size: 1.05rem;
    color: var(--gray-600);
    max-width: 650px;
    margin: 0 auto;
}

/* ============================================
   Tool Section
   ============================================ */
.tool-section {
    display: grid;
    gap: 24px;
    margin-bottom: 40px;
}

@media (min-width: 768px) {
    .tool-section {
        grid-template-columns: 1.2fr 1fr;
    }
}

/* Input Panel */
.input-panel {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-md);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.panel-header h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-700);
}

.input-actions {
    display: flex;
    gap: 8px;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
    background: var(--gray-100);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    cursor: pointer;
    font-family: inherit;
    color: var(--gray-600);
    transition: all 0.2s;
}

.btn-sm:hover {
    background: var(--gray-200);
    color: var(--gray-800);
}

#text-input {
    width: 100%;
    padding: 16px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-family: var(--font-mono);
    font-size: 0.9rem;
    line-height: 1.5;
    resize: vertical;
    min-height: 200px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

#text-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

#text-input::placeholder {
    color: var(--gray-400);
}

.input-meta {
    display: flex;
    gap: 16px;
    margin-top: 8px;
    font-size: 0.8rem;
    color: var(--gray-500);
}

/* Results Panel */
.results-panel {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.result-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-md);
}

.card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}

.card-icon {
    font-size: 1.25rem;
}

.card-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-700);
}

/* Primary Token Card */
.primary-card {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: var(--white);
}

.primary-card .card-header h3 {
    color: var(--white);
}

.token-display {
    text-align: center;
    margin-bottom: 8px;
}

.token-count {
    font-size: 3rem;
    font-weight: 700;
    font-family: var(--font-mono);
    display: block;
}

.token-label {
    font-size: 1rem;
    opacity: 0.9;
}

.token-note {
    text-align: center;
    font-size: 0.85rem;
    opacity: 0.8;
}

/* Model Selector */
.model-selector,
.output-ratio {
    background: var(--white);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
}

.model-selector label,
.output-ratio label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--gray-600);
    margin-bottom: 8px;
}

.model-selector select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.95rem;
    background: var(--white);
    cursor: pointer;
}

.model-selector select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.ratio-input {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ratio-input input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-family: var(--font-mono);
    font-size: 0.95rem;
}

.ratio-input input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.ratio-hint {
    font-size: 0.85rem;
    color: var(--gray-500);
}

/* Cost Card */
.cost-breakdown {
    margin-bottom: 16px;
}

.cost-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--gray-100);
}

.cost-row:last-child {
    border-bottom: none;
}

.cost-row.total {
    border-top: 2px solid var(--gray-200);
    padding-top: 12px;
    margin-top: 4px;
    font-weight: 600;
}

.cost-label {
    color: var(--gray-600);
    font-size: 0.9rem;
}

.cost-value {
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--gray-800);
}

.cost-row.total .cost-value {
    color: var(--primary);
    font-size: 1.1rem;
}

.cost-projections {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding: 12px;
    background: var(--gray-50);
    border-radius: var(--radius);
}

.projection {
    text-align: center;
}

.projection-value {
    display: block;
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--gray-800);
}

.projection-label {
    font-size: 0.75rem;
    color: var(--gray-500);
}

/* Buttons */
.btn {
    padding: 12px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    width: 100%;
}

.btn-copy {
    background: var(--gray-800);
    color: var(--white);
}

.btn-copy:hover {
    background: var(--gray-900);
}

.copy-message {
    font-size: 0.85rem;
    color: var(--secondary);
    text-align: center;
    margin-top: 8px;
    min-height: 20px;
}

/* ============================================
   Comparison Section
   ============================================ */
.comparison-section {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-md);
}

.comparison-section h2 {
    font-size: 1.25rem;
    margin-bottom: 8px;
}

.section-subtitle {
    color: var(--gray-500);
    font-size: 0.95rem;
    margin-bottom: 20px;
}

.table-wrapper {
    overflow-x: auto;
}

.comparison-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.comparison-table th,
.comparison-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
}

.comparison-table th {
    background: var(--gray-50);
    font-weight: 600;
    color: var(--gray-700);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.comparison-table tbody tr:hover {
    background: var(--gray-50);
}

.comparison-table td:nth-child(3),
.comparison-table td:nth-child(4),
.comparison-table td:nth-child(5) {
    font-family: var(--font-mono);
}

.comparison-table .cheapest {
    background: var(--secondary-light);
}

.comparison-table .cheapest td:last-child {
    color: var(--secondary);
    font-weight: 600;
}

/* ============================================
   Content Sections
   ============================================ */
.content-section {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 30px 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}

.content-section h2 {
    font-size: 1.5rem;
    color: var(--gray-900);
    margin-bottom: 16px;
}

.content-section h3 {
    font-size: 1.1rem;
    color: var(--gray-800);
    margin-top: 24px;
    margin-bottom: 12px;
}

.content-section p {
    color: var(--gray-600);
    margin-bottom: 16px;
}

.content-section ul,
.content-section ol {
    margin-bottom: 16px;
    padding-left: 24px;
}

.content-section li {
    color: var(--gray-600);
    margin-bottom: 8px;
}

/* Steps List */
.steps-list {
    counter-reset: steps;
    list-style: none;
    padding-left: 0;
}

.steps-list li {
    counter-increment: steps;
    position: relative;
    padding-left: 48px;
    margin-bottom: 16px;
}

.steps-list li::before {
    content: counter(steps);
    position: absolute;
    left: 0;
    top: 0;
    width: 32px;
    height: 32px;
    background: var(--primary);
    color: var(--white);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
}

/* Token Examples */
.token-examples {
    display: grid;
    gap: 12px;
    margin: 16px 0;
}

.example {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--gray-50);
    border-radius: var(--radius);
}

.example-text {
    font-family: var(--font-mono);
    color: var(--gray-800);
}

.example-tokens {
    font-weight: 600;
    color: var(--primary);
}

/* Tips Grid */
.tips-grid {
    display: grid;
    gap: 16px;
    margin-top: 20px;
}

@media (min-width: 600px) {
    .tips-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.tip-card {
    background: var(--gray-50);
    padding: 20px;
    border-radius: var(--radius);
}

.tip-icon {
    font-size: 1.5rem;
    display: block;
    margin-bottom: 8px;
}

.tip-card h3 {
    margin-top: 0;
    font-size: 1rem;
}

.tip-card p {
    margin-bottom: 0;
    font-size: 0.9rem;
}

/* Pricing Tables */
.pricing-tables {
    display: grid;
    gap: 20px;
    margin: 20px 0;
}

@media (min-width: 768px) {
    .pricing-tables {
        grid-template-columns: repeat(3, 1fr);
    }
}

.pricing-table {
    background: var(--gray-50);
    padding: 16px;
    border-radius: var(--radius);
}

.pricing-table h3 {
    margin-top: 0;
    margin-bottom: 12px;
    font-size: 1rem;
}

.pricing-table table {
    width: 100%;
    font-size: 0.85rem;
    border-collapse: collapse;
}

.pricing-table th,
.pricing-table td {
    padding: 8px 4px;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
}

.pricing-table th {
    color: var(--gray-500);
    font-weight: 500;
    font-size: 0.75rem;
}

.pricing-table td {
    font-family: var(--font-mono);
    font-size: 0.8rem;
}

.pricing-note {
    font-size: 0.85rem;
    color: var(--gray-500);
    margin-top: 16px;
}

/* ============================================
   FAQ
   ============================================ */
.faq-item {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    margin-bottom: 12px;
    overflow: hidden;
}

.faq-item summary {
    padding: 16px 20px;
    cursor: pointer;
    font-weight: 600;
    color: var(--gray-800);
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.2s;
}

.faq-item summary:hover {
    background: var(--gray-50);
}

.faq-item summary::after {
    content: "+";
    font-size: 1.25rem;
    color: var(--gray-400);
    transition: transform 0.2s;
}

.faq-item[open] summary::after {
    transform: rotate(45deg);
}

.faq-item p {
    padding: 0 20px 16px;
    margin: 0;
}

/* ============================================
   Ad Container
   ============================================ */
.ad-container {
    margin: 30px 0;
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ad-placeholder {
    background: var(--gray-100);
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius);
    padding: 40px;
    color: var(--gray-400);
    font-size: 0.9rem;
    text-align: center;
    width: 100%;
}

/* ============================================
   Footer
   ============================================ */
.footer {
    background: var(--gray-800);
    color: var(--gray-300);
    padding: 40px 0 24px;
    margin-top: auto;
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 24px;
    margin-bottom: 24px;
}

.footer-brand .logo {
    color: var(--white);
    display: block;
    margin-bottom: 8px;
}

.footer-brand p {
    font-size: 0.9rem;
    max-width: 300px;
}

.footer-links {
    display: flex;
    gap: 24px;
}

.footer-links a {
    color: var(--gray-300);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.2s;
}

.footer-links a:hover {
    color: var(--white);
}

.footer-bottom {
    border-top: 1px solid var(--gray-700);
    padding-top: 24px;
    text-align: center;
    font-size: 0.85rem;
}

.footer-bottom p {
    margin-bottom: 4px;
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 600px) {
    .hero h1 {
        font-size: 1.5rem;
    }
    
    .token-count {
        font-size: 2.5rem;
    }
    
    .cost-projections {
        grid-template-columns: 1fr;
    }
    
    .footer-content {
        flex-direction: column;
    }
}