:root {
    --green: #7a9d8b;
    --green-dark: #5c7d6e;
    --green-light: #e8f0ec;
    --warm: #e07a5f;
    --cream: #fdf8f4;
    --text: #4a3728;
    --text-light: #8b7355;
    --white: #ffffff;
    --shadow-sm: 0 1px 3px rgba(74, 55, 40, 0.08);
    --shadow-md: 0 4px 16px rgba(74, 55, 40, 0.10);
    --shadow-lg: 0 8px 32px rgba(74, 55, 40, 0.12);
    --radius: 14px;
    --radius-sm: 8px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Noto Sans KR', 'Noto Sans SC', sans-serif;
}

body {
    background-color: #f0f7f4;
    color: var(--text);
    background-image: url("/static/images/bg-coffee.jpg");
    background-size: cover;
    background-position: center 35%;
    background-repeat: no-repeat;
    background-attachment: fixed;
    position: relative;
}

body::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(245, 240, 235, 0.55);
    z-index: -1;
}

/* ---- Header ---- */
header {
    background-color: rgba(122, 157, 139, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 1rem 2rem;
    box-shadow: 0 2px 16px rgba(74, 55, 40, 0.12);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-container {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.8rem;
    font-weight: 700;
    color: white;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    letter-spacing: -0.5px;
}

.logo::before {
    content: "☕";
    font-size: 2rem;
}

nav ul {
    display: flex;
    gap: 2rem;
    list-style: none;
}

nav a {
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    font-weight: 600;
    font-size: 1.05rem;
    cursor: pointer;
    padding: 0.3rem 0.5rem;
    border-radius: 6px;
    transition: all 0.2s ease;
}

nav a:hover {
    color: white;
    background: rgba(255,255,255,0.15);
}

/* ---- Container ---- */
.container {
    max-width: 1400px;
    margin: 4rem auto;
    padding: 2rem;
    display: grid;
    grid-template-columns: 280px 1fr 370px;
    gap: 2rem;
    background-color: var(--cream);
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
}

/* ---- Cards ---- */
.sidebar-left {
    min-height: 550px;
}

.sidebar-left, .sidebar-right, .practice-area {
    background: var(--white);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm), 0 0 0 1px rgba(122, 157, 139, 0.08);
    transition: box-shadow 0.3s ease;
}

.sidebar-left h3, .sidebar-right h3 {
    color: var(--green);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
}

/* ---- Cup Progress ---- */
.cup-progress { margin: 1rem 0; }

.cup-level {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-bottom: 0.3rem;
}

.cup-bar {
    flex: 1;
    height: 10px;
    background: #e8e3df;
    border-radius: 5px;
    overflow: hidden;
}

.cup-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--green), var(--warm));
    border-radius: 5px;
    transition: width 0.4s ease;
}

.cup-label {
    font-size: 0.75rem;
    color: var(--text-light);
    margin-bottom: 0.8rem;
    padding-left: 2rem;
}

/* ---- Config (legacy, mostly overridden inline) ---- */
.text-config {
    display: grid;
    grid-template-columns: repeat(3,1fr);
    gap: 1rem;
    margin-bottom: 1rem;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: var(--radius-sm);
}

.config-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.config-label {
    font-size: 0.9rem;
    color: #666;
}

.config-btn {
    padding: 0.4rem 0.7rem;
    border: 1px solid var(--green);
    border-radius: 20px;
    background: white;
    color: var(--green);
    cursor: pointer;
    transition: all 0.2s ease;
}

.config-btn:hover {
    background: var(--green-light);
}

.config-btn.active {
    background: var(--green);
    color: white;
}

/* ---- Text Display ---- */
.target-text {
    margin-top: 1.2rem;
    margin-bottom: 0.4rem;
    font-size: 1.1rem;
    line-height: 1.6;
    min-height: 3rem;
}

.translation {
    margin-bottom: 0.6rem;
    color: var(--text-light);
    font-size: 0.95rem;
}

.text-display {
    background: #f8f9fa;
    padding: 1.5rem;
    border-radius: var(--radius-sm);
    font-size: 1.1rem;
    min-height: 120px;
    margin-bottom: 1rem;
    white-space: pre-wrap;
}

.correct { color: var(--green); font-weight: bold; }
.incorrect { color: #e53e3e; text-decoration: underline wavy #e53e3e; }
.current { border-right: 2px solid var(--green); animation: blink 1s infinite; }

@keyframes blink { 50% { border-color: transparent; } }

/* ---- Input ---- */
.input-area {
    width: 100%;
    padding: 1rem;
    border: 2px solid #d4cdc5;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    height: 130px;
    font-size: 1.1rem;
    resize: none;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.input-area:focus {
    border-color: var(--green);
    box-shadow: 0 0 0 3px rgba(122, 157, 139, 0.15);
}

/* ---- Stats ---- */
.stats {
    display: flex;
    gap: 1.5rem;
    margin: 1rem 0;
    color: var(--text-light);
    font-size: 0.9rem;
}

.stat-value {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--text);
}

/* ---- Buttons ---- */
.control-buttons {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

.control-btn {
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
}

.start-btn {
    background: var(--green);
    color: white;
}

.start-btn:hover {
    background: var(--green-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(122, 157, 139, 0.35);
}

.start-btn:active {
    transform: translateY(0);
}

.submit-btn {
    background: var(--warm);
    color: white;
}

.submit-btn:hover {
    background: #c96a50;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(224, 122, 95, 0.35);
}

.submit-btn:active {
    transform: translateY(0);
}

.reset-btn {
    background: #f5f0eb;
    color: var(--text-light);
}

.reset-btn:hover {
    background: #e8e3df;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(74, 55, 40, 0.12);
}

.reset-btn:active {
    transform: translateY(0);
}

.control-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* ---- AI Coach ---- */
.ai-coach {
    background: #fdf8f4;
    padding: 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    border-left: 4px solid var(--green);
}

/* ---- Modal ---- */
@keyframes fadeIn {
    from { opacity: 0; transform: translate(-50%, -50%) scale(0.95); }
    to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

@keyframes fadeOut {
    from { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    to { opacity: 0; transform: translate(-50%, -50%) scale(0.95); }
}

/* ---- Topic Panel (AI 咖啡师左侧) ---- */
.topic-panel h3 {
    color: var(--green);
    margin-bottom: 0.8rem;
    font-size: 0.95rem;
}

.topic-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    margin-bottom: 1rem;
}

.topic-btn {
    width: 100%;
    padding: 0.55rem 0.8rem;
    border: 1px solid #d4cdc5;
    border-radius: 8px;
    background: white;
    color: var(--text);
    cursor: pointer;
    font-size: 0.85rem;
    text-align: left;
    transition: all 0.2s ease;
}

.topic-btn:hover {
    border-color: var(--green);
    color: var(--green);
    background: #f0f7f4;
    transform: translateX(2px);
}

.topic-btn.random {
    border-style: dashed;
    color: var(--text-light);
    text-align: center;
}

.topic-btn.random:hover {
    border-style: dashed;
    color: var(--warm);
    border-color: var(--warm);
    background: #fdf0e8;
}

.daily-tip {
    margin-top: 1.5rem;
    background: #fdf8f4;
    border-radius: 8px;
    padding: 0.8rem;
    border-left: 3px solid var(--green);
}

.daily-tip strong {
    display: block;
    font-size: 0.8rem;
    color: var(--green);
    margin-bottom: 0.3rem;
}

.daily-tip p {
    font-size: 0.82rem;
    color: var(--text-light);
    line-height: 1.5;
}

/* ---- Chat Container (AI 咖啡师) ---- */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 550px;
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.8rem;
    padding-bottom: 0.6rem;
    border-bottom: 1px solid #e8e3df;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--green);
}

.chat-status {
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 10px;
    background: #e8f0ec;
    color: var(--green);
    transition: all 0.3s ease;
}

.chat-status.loading {
    background: #fdf0e8;
    color: var(--warm);
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ---- Chat Messages ---- */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding-right: 4px;
    margin-bottom: 0.6rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.chat-messages::-webkit-scrollbar {
    width: 4px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #d4cdc5;
    border-radius: 2px;
}

.chat-bubble {
    max-width: 92%;
    padding: 0.6rem 0.8rem;
    border-radius: 12px;
    font-size: 0.95rem;
    line-height: 1.6;
    word-break: break-word;
    animation: fadeIn 0.25s ease;
}

.ai-bubble {
    background: #f0f7f4;
    border-top-left-radius: 4px;
    align-self: flex-start;
    color: var(--text);
}

.user-bubble {
    background: var(--green);
    color: white;
    border-top-right-radius: 4px;
    align-self: flex-end;
}

/* ---- Quick Actions ---- */
.chat-quick-actions {
    display: flex;
    gap: 0.4rem;
    margin-bottom: 0.6rem;
    flex-wrap: wrap;
}

.quick-btn {
    flex: 1;
    min-width: 0;
    padding: 0.35rem 0.5rem;
    border: 1px solid #d4cdc5;
    border-radius: 8px;
    background: white;
    color: var(--text-light);
    cursor: pointer;
    font-size: 0.75rem;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.quick-btn:hover:not(:disabled) {
    border-color: var(--green);
    color: var(--green);
    background: #f0f7f4;
}

.quick-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ---- Chat Input ---- */
.chat-input-row {
    display: flex;
    gap: 0.4rem;
}

.chat-input-row input {
    flex: 1;
    padding: 0.5rem 0.7rem;
    border: 1px solid #d4cdc5;
    border-radius: 8px;
    outline: none;
    font-size: 0.85rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.chat-input-row input:focus {
    border-color: var(--green);
    box-shadow: 0 0 0 2px rgba(122, 157, 139, 0.12);
}

.chat-input-row input:disabled {
    background: #f5f0eb;
}

.chat-input-row button {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 8px;
    background: var(--green);
    color: white;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.chat-input-row button:hover:not(:disabled) {
    background: var(--green-dark);
}

.chat-input-row button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ---- Responsive ---- */
@media (max-width: 1024px) {
    .container { grid-template-columns: 1fr; }
    .text-config { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
    .header-container { flex-direction: column; gap: 0.5rem; }
    .container { padding: 1rem; margin: 1rem; }
}
