@charset "UTF-8";

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

:root {
    --header-h: 60px;
    --footer-h: 80px;
    --sidebar-w: 280px;
}

html,
body {
    height: 100%;
    overflow: hidden;
    font-family: 'Noto Sans KR', sans-serif;
}

/* ──────────── HEADER ──────────── */
header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 100;
}

header.light {
    background: #3a3a3a;
}

header.dark {
    background: #c0c0c0;
}

h1 {
    font-size: 32px;
    color: #fff;
}

#mode-wrap {
    position: relative;
}

#mode-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: #fff;
    border: none;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

#mode-btn:hover {
    background: #646;
}

#mode-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
    display: none;
    flex-direction: column;
    min-width: 150px;
    overflow: hidden;
    z-index: 200;
}

#mode-dropdown.open {
    display: flex;
}

.mode-option {
    padding: 13px 18px;
    cursor: pointer;
    font-size: 14px;
    border-bottom: 1px solid #f0f0f0;
    transition: all 0.15s;
}

.mode-option:last-child {
    border-bottom: none;
}

.mode-option:hover {
    background: #f5f5f5;
}

/* ──────────── LAYOUT SHELL ──────────── */
#shell {
    position: fixed;
    top: var(--header-h);
    bottom: var(--footer-h);
    left: 0;
    right: 0;
    display: flex;
}

/* ──────────── SIDEBAR ──────────── */
#sidebar {
    width: var(--sidebar-w);
    background: #6b6b6b;
    flex-shrink: 0;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
    transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

#sidebar-title {
    color: rgba(255, 255, 255, 0.5);
    font-size: 16px;
    letter-spacing: 0.1em;
    padding: 14px 14px 8px;
    white-space: nowrap;
    flex-shrink: 0;
}

.record-item {
    color: white;
    padding: 12px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
    white-space: nowrap;
}

.record-time {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 0.02em;
    margin-bottom: 3px;
}

.record-phrase {
    font-size: 11px;
    opacity: 0.7;
    line-height: 1.4;
}

#sidebar-empty {
    color: rgba(255, 255, 255, 0.35);
    font-size: 12px;
    text-align: center;
    padding: 30px 14px;
    white-space: nowrap;
}

/* 모바일용 사이드바 핸들 (기본은 숨김) */
#sidebar-handle {
    display: none;
}

/* ──────────── MAIN CONTENT ──────────── */
#main {
    flex: 1;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    transition: background 0.4s;
    overflow: hidden;
}

#main.dark {
    background: #000000;
}

#main.dark #timer-display {
    color: white;
}

#main.dark #phrase-display {
    color: rgba(255, 255, 255, 0.85);
}

#main.rainbow {
    background: linear-gradient(180deg,
            #ff0000 0%, #ff6600 14%, #ffcc00 28%,
            #33cc00 42%, #0066ff 57%, #6600cc 71%,
            #cc00ff 85%, #ff0066 100%);
    animation: rainbowShift 3s linear infinite;
}

#main.rainbow #timer-display {
    color: white;
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}

#main.rainbow #phrase-display {
    color: white;
}

@keyframes rainbowShift {
    0% {
        filter: hue-rotate(0deg);
    }

    100% {
        filter: hue-rotate(360deg);
    }
}

#timer-display {
    font-size: clamp(80px, 14vw, 200px);
    font-weight: 900;
    letter-spacing: -0.02em;
    color: #111;
    line-height: 1;
    margin-bottom: 44px;
    font-variant-numeric: tabular-nums;
    transition: color 0.3s;
    user-select: none;
}

#timer-btn {
    width: 260px;
    height: 62px;
    border-radius: 31px;
    border: none;
    background: #d0d0d0;
    font-size: 20px;
    font-family: 'Noto Sans KR', sans-serif;
    font-weight: 500;
    cursor: pointer;
    margin-bottom: 22px;
    transition: all 0.2s, transform 0.1s;
}

#timer-btn:active {
    transform: scale(0.97);
}

#timer-btn.running {
    background: #e53935;
    color: white;
}

#phrase-display {
    font-size: 18px;
    color: #444;
    height: 62px;
    width: 600px;
    max-width: 80%;
    background: rgba(0, 0, 0, 0.06);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.4s, color 0.3s;
    text-align: center;
    padding: 0 20px;
}

#phrase-display.visible {
    opacity: 1;
}

/* ──────────── CHARACTER ──────────── */
#character-wrap {
    position: absolute;
    bottom: 0;
    right: 24px;
    width: 200px;
    height: 280px;
}

#character-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: bottom;
    transform-origin: center bottom;
}

#character-img.dark-mode {
    filter: invert(1);
}

#character-img.rainbow-mode {
    filter: saturate(3);
    animation: rainbowChar 3s linear infinite;
}

@keyframes rainbowChar {
    0% {
        filter: hue-rotate(0deg) saturate(3);
    }

    100% {
        filter: hue-rotate(360deg) saturate(3);
    }
}

#character-img.dancing {
    animation: dance 0.5s steps(1, end) infinite;
}

#character-img.dancing.dark-mode {
    animation: danceDark 0.5s steps(1, end) infinite;
}

#character-img.dancing.rainbow-mode {
    animation: danceRainbow 0.5s steps(1, end) infinite;
}

@keyframes dance {
    0% {
        transform: scaleX(1);
        filter: none;
    }

    50% {
        transform: scaleX(-1);
        filter: none;
    }
}

@keyframes danceDark {
    0% {
        transform: scaleX(1);
        filter: invert(1);
    }

    50% {
        transform: scaleX(-1);
        filter: invert(1);
    }
}

@keyframes danceRainbow {
    0% {
        transform: scaleX(1);
        filter: hue-rotate(0deg) saturate(3);
    }

    25% {
        filter: hue-rotate(90deg) saturate(3);
    }

    50% {
        transform: scaleX(-1);
        filter: hue-rotate(180deg) saturate(3);
    }

    75% {
        filter: hue-rotate(270deg) saturate(3);
    }
}

/* ──────────── FOOTER ──────────── */
footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--footer-h);
    z-index: 50;
}

footer.light {
    background: #3a3a3a;
}

footer.dark {
    background: #c0c0c0;
}

/* ──────────── WARNING POPUP ──────────── */
#popup-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 500;
}

#popup-overlay.show {
    display: flex;
}

#popup-box {
    background: white;
    border-radius: 20px;
    padding: 48px 40px;
    text-align: center;
    max-width: 420px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}

#popup-box .popup-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

#popup-box h2 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 12px;
    color: #111;
}

#popup-box p {
    font-size: 15px;
    color: #666;
    line-height: 1.7;
    margin-bottom: 28px;
}

#popup-close {
    background: #e53935;
    color: white;
    border: none;
    border-radius: 10px;
    padding: 13px 40px;
    font-size: 16px;
    font-family: 'Noto Sans KR', sans-serif;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

#popup-close:hover {
    background: #c62828;
}

/* Scrollbar */
#sidebar::-webkit-scrollbar {
    width: 4px;
}

#sidebar::-webkit-scrollbar-track {
    background: transparent;
}

#sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.25);
    border-radius: 2px;
}

/* ──────────── 유틸리티 ──────────── */
.flip-horizontal {
    transform: scaleX(-1);
}
