:root {
    --bg: #f4efe7;
    --bg-accent: #e6dac6;
    --panel: rgba(255, 251, 245, 0.82);
    --panel-strong: #fffdf8;
    --line: rgba(94, 72, 40, 0.14);
    --text: #1f1a17;
    --muted: #756555;
    --primary: #b15c2f;
    --primary-soft: #f3d3bc;
    --success: #2f7d4d;
    --warning: #c58a17;
    --danger: #c64132;
    --shadow: 0 24px 60px rgba(73, 47, 23, 0.12);
    --radius-xl: 28px;
    --radius-lg: 20px;
    --radius-md: 14px;
}

* {
    box-sizing: border-box;
}

html {
    font-size: 16px;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "IBM Plex Sans KR", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(255, 255, 255, 0.7), transparent 32%),
        radial-gradient(circle at bottom right, rgba(177, 92, 47, 0.18), transparent 30%),
        linear-gradient(135deg, var(--bg) 0%, #efe6db 48%, #f8f3ed 100%);
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(94, 72, 40, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(94, 72, 40, 0.03) 1px, transparent 1px);
    background-size: 36px 36px;
    mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.45), transparent 78%);
}

.page-shell {
    width: min(1200px, calc(100% - 32px));
    margin: 0 auto;
    padding: 48px 0 64px;
}

.hero {
    display: block;
    margin-bottom: 28px;
}

.panel {
    border: 1px solid var(--line);
    border-radius: var(--radius-xl);
    background: var(--panel);
    backdrop-filter: blur(18px);
    box-shadow: var(--shadow);
}

.hero-copy {
    padding: 8px 4px 2px;
}

.eyebrow,
.panel-kicker {
    margin: 0 0 10px;
    font-family: "Space Grotesk", sans-serif;
    font-size: 0.84rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--primary);
}

.hero h1 {
    margin: 0;
    font-size: clamp(2rem, 4vw, 3.9rem);
    line-height: 1.05;
    letter-spacing: -0.04em;
}

.hero-text {
    margin: 18px 0 0;
    font-size: 1.05rem;
    line-height: 1.7;
    color: var(--muted);
}

.workspace {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.9fr);
    gap: 24px;
}

.panel {
    padding: 24px;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
    margin-bottom: 18px;
}

.panel-header.compact {
    margin-bottom: 16px;
}

.panel-header h2,
.insight-card h3 {
    margin: 0;
    font-size: 1.3rem;
}

.limit-group {
    display: grid;
    gap: 8px;
}

.limit-group label {
    font-size: 0.9rem;
    color: var(--muted);
}

.limit-input-wrap {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--panel-strong);
}

.limit-input-wrap input {
    width: 88px;
    border: 0;
    padding: 0;
    font: inherit;
    font-weight: 600;
    color: var(--text);
    background: transparent;
    outline: none;
}

.preset-group {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 18px;
}

.preset-btn,
.secondary-btn,
.ghost-btn {
    appearance: none;
    border: 1px solid var(--line);
    border-radius: 999px;
    font: inherit;
    cursor: pointer;
    transition: transform 140ms ease, background-color 140ms ease, border-color 140ms ease, color 140ms ease;
}

.preset-btn {
    padding: 9px 14px;
    color: var(--muted);
    background: rgba(255, 255, 255, 0.64);
}

.preset-btn:hover,
.secondary-btn:hover,
.ghost-btn:hover {
    transform: translateY(-1px);
}

.preset-btn.active {
    color: #fff;
    background: var(--primary);
    border-color: var(--primary);
}

.editor-label {
    display: block;
    margin-bottom: 10px;
    font-size: 0.95rem;
    font-weight: 600;
}

.essay-input {
    width: 100%;
    min-height: 460px;
    resize: vertical;
    padding: 22px 20px;
    border: 1px solid var(--line);
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.7);
    font: inherit;
    font-size: 1rem;
    line-height: 1.75;
    color: var(--text);
    outline: none;
    transition: border-color 160ms ease, box-shadow 160ms ease, background-color 160ms ease;
}

.essay-input:focus {
    border-color: rgba(177, 92, 47, 0.45);
    box-shadow: 0 0 0 5px rgba(177, 92, 47, 0.09);
    background: rgba(255, 255, 255, 0.92);
}

.editor-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 16px;
}

.secondary-btn,
.ghost-btn {
    padding: 11px 16px;
}

.secondary-btn {
    color: #fff;
    background: var(--text);
    border-color: var(--text);
}

.ghost-btn {
    color: var(--text);
    background: transparent;
}

.save-status {
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(47, 125, 77, 0.12);
    color: var(--success);
    font-size: 0.9rem;
    font-weight: 600;
}

.save-status.pending {
    background: rgba(197, 138, 23, 0.12);
    color: var(--warning);
}

.progress-card {
    padding: 18px;
    border-radius: var(--radius-lg);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(243, 211, 188, 0.42));
    border: 1px solid rgba(94, 72, 40, 0.09);
}

.progress-card.warning {
    border-color: rgba(197, 138, 23, 0.28);
}

.progress-card.danger {
    border-color: rgba(198, 65, 50, 0.3);
}

.progress-meta {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    margin-bottom: 12px;
}

.progress-meta span {
    color: var(--muted);
}

.progress-meta strong {
    font-family: "Space Grotesk", sans-serif;
    font-size: 1.3rem;
}

.progress-track {
    position: relative;
    height: 14px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(94, 72, 40, 0.1);
}

.progress-bar {
    height: 100%;
    width: 0;
    border-radius: inherit;
    background: linear-gradient(90deg, #d47934 0%, #b15c2f 100%);
    transition: width 180ms ease, background 180ms ease;
}

.progress-card.warning .progress-bar {
    background: linear-gradient(90deg, #d8b33e 0%, #c58a17 100%);
}

.progress-card.danger .progress-bar {
    background: linear-gradient(90deg, #d96253 0%, #c64132 100%);
}

.limit-feedback {
    margin: 14px 0 0;
    color: var(--muted);
    line-height: 1.6;
}

.stats-grid,
.insight-grid {
    display: grid;
    gap: 14px;
    margin-top: 16px;
}

.stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.stat-card,
.insight-card {
    padding: 18px;
    border: 1px solid rgba(94, 72, 40, 0.1);
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, 0.68);
}

.stat-label {
    display: block;
    margin-bottom: 10px;
    color: var(--muted);
    font-size: 0.93rem;
}

.stat-value {
    font-family: "Space Grotesk", sans-serif;
    font-size: clamp(1.6rem, 3vw, 2.3rem);
    letter-spacing: -0.03em;
}

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

.insight-note {
    font-size: 0.86rem;
    color: var(--muted);
}

.token-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.token-list.empty {
    color: var(--muted);
    line-height: 1.6;
}

.token-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 999px;
    background: rgba(177, 92, 47, 0.1);
    color: #6d3517;
    font-size: 0.94rem;
}

.token-chip strong {
    font-family: "Space Grotesk", sans-serif;
}

.check-list {
    margin: 0;
    padding-left: 18px;
    color: var(--text);
    line-height: 1.7;
}

.check-list li + li {
    margin-top: 8px;
}

@media (max-width: 980px) {
    .workspace {
        grid-template-columns: 1fr;
    }

    .essay-input {
        min-height: 360px;
    }
}

@media (max-width: 640px) {
    .page-shell {
        width: min(100% - 20px, 1200px);
        padding: 20px 0 32px;
    }

    .panel {
        border-radius: 24px;
    }

    .panel {
        padding: 20px;
    }

    .panel-header {
        flex-direction: column;
        align-items: stretch;
    }

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

    .editor-actions {
        justify-content: stretch;
    }

    .secondary-btn,
    .ghost-btn {
        width: 100%;
    }
}
