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

:root {
    --bg-primary: #0d1117;
    --bg-card: #161b22;
    --bg-card-hover: #1c2330;
    --border-color: #30363d;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    --accent: #f97316;
    --accent-hover: #fb923c;
    --accent-glow: rgba(249, 115, 22, 0.15);
    --score-red: #ef4444;
    --score-yellow: #eab308;
    --score-green: #22c55e;
    --problem-red: #ef4444;
    --problem-bg: rgba(239, 68, 68, 0.08);
    --strength-green: #22c55e;
    --strength-bg: rgba(34, 197, 94, 0.08);
    --radius: 12px;
    --radius-sm: 8px;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100dvh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    color: var(--accent-hover);
}

/* === Layout === */
.app {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 16px;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    padding-bottom: env(safe-area-inset-bottom, 0);
}

/* === Header === */
.header {
    padding: 20px 0 16px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 24px;
}

.logo-link {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: inherit;
}

.logo-fire {
    font-size: 36px;
    line-height: 1;
}

.logo-text h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 400;
}

/* === Input Section === */
.input-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 40px 0;
}

.input-hero {
    text-align: center;
    margin-bottom: 32px;
}

.hero-text {
    font-size: 17px;
    color: var(--text-secondary);
    max-width: 500px;
    line-height: 1.6;
}

.url-form {
    width: 100%;
    max-width: 560px;
}

.url-input-wrapper {
    display: flex;
    gap: 0;
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
    transition: border-color 0.2s;
}

.url-input-wrapper:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.url-input {
    flex: 1;
    padding: 14px 16px;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 16px;
    outline: none;
    min-width: 0;
}

.url-input::placeholder {
    color: var(--text-muted);
}

.roast-btn {
    padding: 14px 24px;
    background: var(--accent);
    color: #fff;
    border: none;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s;
}

.roast-btn:hover {
    background: var(--accent-hover);
}

.roast-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.input-hint {
    margin-top: 16px;
    font-size: 13px;
    color: var(--text-muted);
    text-align: center;
}

/* === Loading Section === */
.loading-section {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 0;
}

.loading-content {
    text-align: center;
}

.loading-fire {
    margin-bottom: 24px;
}

.fire-emoji {
    font-size: 64px;
    display: inline-block;
    animation: pulse-fire 1.5s ease-in-out infinite;
}

@keyframes pulse-fire {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.15); opacity: 0.8; }
}

.loading-title {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 8px;
}

.loading-dots::after {
    content: '';
    animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
    0% { content: ''; }
    25% { content: '.'; }
    50% { content: '..'; }
    75% { content: '...'; }
}

.loading-url {
    font-size: 14px;
    color: var(--accent);
    margin-bottom: 16px;
    word-break: break-all;
}

.loading-hint {
    font-size: 14px;
    color: var(--text-muted);
    max-width: 400px;
    margin: 0 auto;
}

/* === Error Section === */
.error-section {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 0;
}

.error-content {
    text-align: center;
}

.error-icon {
    font-size: 48px;
    display: block;
    margin-bottom: 16px;
}

.error-title {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 8px;
}

.error-text {
    font-size: 15px;
    color: var(--text-secondary);
    margin-bottom: 24px;
    max-width: 400px;
}

.retry-btn {
    padding: 12px 28px;
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 15px;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.retry-btn:hover {
    background: var(--bg-card-hover);
    border-color: var(--text-muted);
}

/* === Results Section === */
.results-section {
    padding: 24px 0 40px;
}

/* Score Hero */
.score-hero {
    text-align: center;
    margin-bottom: 32px;
}

.score-circle {
    position: relative;
    width: 140px;
    height: 140px;
    margin: 0 auto 20px;
}

.score-svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.score-ring-bg {
    fill: none;
    stroke: var(--border-color);
    stroke-width: 6;
}

.score-ring {
    fill: none;
    stroke: var(--accent);
    stroke-width: 6;
    stroke-linecap: round;
    stroke-dasharray: 339.292;
    stroke-dashoffset: 339.292;
    transition: stroke-dashoffset 1.2s ease-out, stroke 0.3s;
}

.score-value {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -60%);
    font-size: 48px;
    font-weight: 700;
    line-height: 1;
}

.score-label {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, 40%);
    font-size: 14px;
    color: var(--text-muted);
}

.score-red .score-ring,
.score-red .score-value { stroke: var(--score-red); color: var(--score-red); }
.score-yellow .score-ring,
.score-yellow .score-value { stroke: var(--score-yellow); color: var(--score-yellow); }
.score-green .score-ring,
.score-green .score-value { stroke: var(--score-green); color: var(--score-green); }

.verdict-text {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    max-width: 500px;
    margin: 0 auto;
}

/* Roast Intro */
.roast-intro {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 32px;
    font-size: 15px;
    line-height: 1.7;
    color: var(--text-secondary);
}

.roast-intro p {
    margin-bottom: 8px;
}

.roast-intro p:last-child {
    margin-bottom: 0;
}

/* === Category Cards === */
.categories-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 32px;
}

.category-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
    transition: background 0.2s, border-color 0.2s, transform 0.2s;
}

.category-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--text-muted);
    transform: translateY(-2px);
}

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

.card-emoji {
    font-size: 24px;
    line-height: 1;
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

/* Score Bar */
.card-score-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
}

.card-score-bar {
    flex: 1;
    height: 8px;
    background: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
}

.card-score-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.8s ease-out;
    width: 0;
}

.card-score-fill.fill-red { background: var(--score-red); }
.card-score-fill.fill-yellow { background: var(--score-yellow); }
.card-score-fill.fill-green { background: var(--score-green); }

.card-score-num {
    font-size: 14px;
    font-weight: 700;
    min-width: 32px;
    text-align: right;
}

.card-score-num.num-red { color: var(--score-red); }
.card-score-num.num-yellow { color: var(--score-yellow); }
.card-score-num.num-green { color: var(--score-green); }

/* Roast Text */
.card-roast {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-secondary);
    margin-bottom: 14px;
}

.card-roast p {
    margin-bottom: 6px;
}

.card-roast p:last-child {
    margin-bottom: 0;
}

/* Fixes List */
.card-fixes {
    list-style: none;
    padding: 0;
}

.card-fixes li {
    position: relative;
    padding-left: 22px;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 6px;
    line-height: 1.5;
}

.card-fixes li:last-child {
    margin-bottom: 0;
}

.card-fixes li::before {
    content: '\2713';
    position: absolute;
    left: 0;
    top: 0;
    color: var(--score-green);
    font-weight: 700;
    font-size: 14px;
}

/* === Highlights (Problems & Strengths) === */
.highlights {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 32px;
}

.highlight-block {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
}

.highlight-problems {
    border: 1px solid rgba(239, 68, 68, 0.25);
    background: var(--problem-bg);
}

.highlight-strengths {
    border: 1px solid rgba(34, 197, 94, 0.25);
    background: var(--strength-bg);
}

.highlight-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.highlight-icon {
    font-size: 16px;
}

.highlight-list {
    list-style: none;
    padding: 0;
}

.highlight-list li {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-secondary);
    margin-bottom: 8px;
    padding-left: 8px;
    border-left: 3px solid transparent;
}

.highlight-list li:last-child {
    margin-bottom: 0;
}

.highlight-problems .highlight-list li {
    border-left-color: var(--problem-red);
}

.highlight-strengths .highlight-list li {
    border-left-color: var(--strength-green);
}

/* === Action Buttons === */
.result-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.share-btn,
.new-roast-btn {
    padding: 12px 28px;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, transform 0.1s;
    border: none;
}

.share-btn:active,
.new-roast-btn:active {
    transform: scale(0.97);
}

.share-btn {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.share-btn:hover {
    background: var(--bg-card-hover);
    border-color: var(--text-muted);
}

.share-icon {
    margin-right: 4px;
}

.new-roast-btn {
    background: var(--accent);
    color: #fff;
}

.new-roast-btn:hover {
    background: var(--accent-hover);
}

/* === Footer === */
.footer {
    padding: 24px 0;
    border-top: 1px solid var(--border-color);
    text-align: center;
    margin-top: auto;
}

.footer p {
    font-size: 13px;
    color: var(--text-muted);
}

/* === Toast === */
.toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}

.toast.show {
    display: block !important;
    opacity: 1;
}

/* === Responsive === */
@media (max-width: 640px) {
    .app {
        padding: 0 12px;
    }

    .header {
        padding: 16px 0 12px;
        margin-bottom: 16px;
    }

    .logo-fire {
        font-size: 28px;
    }

    .logo-text h1 {
        font-size: 20px;
    }

    .subtitle {
        font-size: 12px;
    }

    .hero-text {
        font-size: 15px;
    }

    .url-input-wrapper {
        flex-direction: column;
    }

    .roast-btn {
        border-top: 1px solid var(--border-color);
    }

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

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

    .score-circle {
        width: 120px;
        height: 120px;
    }

    .score-value {
        font-size: 40px;
    }

    .verdict-text {
        font-size: 18px;
    }

    .loading-title {
        font-size: 19px;
    }

    .fire-emoji {
        font-size: 48px;
    }

    .result-actions {
        flex-direction: column;
    }

    .share-btn,
    .new-roast-btn {
        width: 100%;
        text-align: center;
    }

    .roast-intro {
        padding: 16px;
    }

    .category-card {
        padding: 16px;
    }

    .highlight-block {
        padding: 16px;
    }
}

/* === Scrollbar (WebKit) === */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Gallery */
.gallery {
    margin-top: 48px;
    width: 100%;
    max-width: 800px;
}

.gallery-title {
    font-size: 1.3rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
    text-align: center;
}

.gallery-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.gallery-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    text-decoration: none;
    color: var(--text-primary);
    transition: border-color 0.2s, transform 0.2s;
}

.gallery-card:hover {
    border-color: var(--accent-color);
    transform: translateY(-2px);
}

.gallery-score {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    font-weight: 700;
    flex-shrink: 0;
    border: 3px solid;
}

.gallery-score.score-red { border-color: var(--score-red); color: var(--score-red); }
.gallery-score.score-yellow { border-color: var(--score-yellow); color: var(--score-yellow); }
.gallery-score.score-green { border-color: var(--score-green); color: var(--score-green); }

.gallery-info {
    flex: 1;
    min-width: 0;
}

.gallery-url {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gallery-verdict {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-top: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.gallery-date {
    font-size: 0.75rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

.gallery-empty {
    text-align: center;
    color: var(--text-muted);
    padding: 24px;
}

@media (max-width: 640px) {
    .gallery-date { display: none; }
}

/* Selection */
::selection {
    background: var(--accent-glow);
    color: var(--text-primary);
}
