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

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --bg: #0f172a;
    --bg-card: #1e293b;
    --bg-input: #334155;
    --text: #f1f5f9;
    --text-secondary: #94a3b8;
    --border: #475569;
    --success: #22c55e;
    --danger: #ef4444;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
}

.app {
    max-width: 500px;
    margin: 0 auto;
    padding: 16px;
    padding-bottom: 100px;
}

/* 인증 화면 */
.auth-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.auth-container {
    width: 100%;
    max-width: 360px;
}

.auth-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 8px;
}

.auth-logo-img {
    width: 48px;
    height: 48px;
    border-radius: 12px;
}

.auth-desc {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 32px;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.auth-form input {
    padding: 14px 16px;
    border: none;
    border-radius: 12px;
    background: var(--bg-input);
    color: var(--text);
    font-size: 16px;
    outline: none;
}

.auth-form input:focus {
    box-shadow: 0 0 0 2px var(--primary);
}

.auth-form .btn-primary {
    margin-top: 8px;
}

.auth-error {
    color: var(--danger);
    font-size: 14px;
    text-align: center;
    min-height: 20px;
}

.auth-switch {
    text-align: center;
    margin-top: 20px;
    color: var(--text-secondary);
}

.auth-switch a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.email-check,
.nickname-check,
.password-match {
    font-size: 13px;
    margin: -8px 0 0 4px;
    min-height: 18px;
}

.email-check.available,
.nickname-check.available,
.password-match.match {
    color: var(--success);
}

.email-check.taken,
.nickname-check.taken,
.password-match.mismatch {
    color: var(--danger);
}

/* 헤더 */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    margin-bottom: 16px;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 20px;
    font-weight: 700;
}

.header-logo .logo-img {
    width: 36px;
    height: 36px;
    border-radius: 8px;
}

.header-btns {
    display: flex;
    gap: 4px;
}

.user-info {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 16px;
    padding: 8px 12px;
    background: var(--bg-card);
    border-radius: 8px;
}

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: background 0.2s;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.btn-icon svg {
    width: 22px;
    height: 22px;
}

/* 할 일 입력 */
.add-todo {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
}

.add-todo input {
    flex: 1;
    padding: 14px 16px;
    border: none;
    border-radius: 12px;
    background: var(--bg-input);
    color: var(--text);
    font-size: 16px;
    outline: none;
}

.add-todo input::placeholder {
    color: var(--text-secondary);
}

.add-todo input:focus {
    box-shadow: 0 0 0 2px var(--primary);
}

/* 버튼 */
.btn-primary {
    padding: 14px 24px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    padding: 8px 16px;
    background: var(--bg-input);
    color: var(--text);
    border: none;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-secondary:hover {
    background: var(--border);
}

.btn-outline {
    padding: 10px 20px;
    background: transparent;
    color: var(--primary);
    border: 2px solid var(--primary);
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-outline:hover {
    background: var(--primary);
    color: white;
}

/* 할 일 목록 */
.todo-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.loading {
    text-align: center;
    color: var(--text-secondary);
    padding: 40px;
}

.empty {
    text-align: center;
    color: var(--text-secondary);
    padding: 60px 20px;
}

.empty-icon {
    margin-bottom: 16px;
    color: var(--text-secondary);
}

/* 할 일 아이템 */
.todo-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: var(--bg-card);
    border-radius: 12px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.todo-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.todo-item.completed {
    opacity: 0.6;
}

.todo-item.completed .todo-title {
    text-decoration: line-through;
    color: var(--text-secondary);
}

.todo-checkbox {
    width: 24px;
    height: 24px;
    border: 2px solid var(--border);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.todo-checkbox:hover {
    border-color: var(--primary);
}

.todo-checkbox.checked {
    background: var(--success);
    border-color: var(--success);
}

.todo-checkbox.checked::after {
    content: '✓';
    color: white;
    font-size: 14px;
    font-weight: bold;
}

.todo-content {
    flex: 1;
    min-width: 0;
    cursor: pointer;
}

.todo-title {
    font-size: 16px;
    font-weight: 500;
    word-break: break-word;
}

.todo-reminder {
    font-size: 12px;
    color: var(--primary);
    margin-top: 4px;
}

.todo-alarm {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all 0.2s;
    opacity: 0.5;
}

.todo-alarm:hover {
    opacity: 1;
}

.todo-alarm.active {
    color: var(--primary);
    opacity: 1;
}

.todo-delete {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all 0.2s;
    opacity: 0;
}

.todo-item:hover .todo-delete,
.todo-item:hover .todo-alarm {
    opacity: 1;
}

.todo-alarm.active {
    opacity: 1;
}

.todo-delete:hover {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

/* 모달 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-card);
    border-radius: 16px;
    width: 100%;
    max-width: 400px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-content.modal-small {
    max-width: 320px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    font-size: 18px;
}

.btn-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 28px;
    cursor: pointer;
    line-height: 1;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
}

.modal-footer .btn-primary {
    width: 100%;
}

/* 설정 */
.setting-group {
    margin-bottom: 24px;
}

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

.setting-row label {
    font-size: 16px;
    font-weight: 500;
}

.setting-desc {
    font-size: 13px;
    color: var(--text-secondary);
}

.setting-label {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.time-input {
    width: 100%;
    padding: 12px;
    background: var(--bg-input);
    border: none;
    border-radius: 8px;
    color: var(--text);
    font-size: 16px;
}

.test-buttons {
    display: flex;
    gap: 12px;
}

.test-buttons button {
    flex: 1;
}

/* 토글 스위치 */
.switch {
    position: relative;
    width: 52px;
    height: 28px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-input);
    border-radius: 28px;
    transition: 0.3s;
}

.slider::before {
    position: absolute;
    content: '';
    height: 22px;
    width: 22px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: 0.3s;
}

.switch input:checked + .slider {
    background: var(--primary);
}

.switch input:checked + .slider::before {
    transform: translateX(24px);
}

/* 통계 */
.stats-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.stats-card {
    background: var(--bg-input);
    border-radius: 12px;
    padding: 16px;
    text-align: center;
}

.stats-card .value {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary);
}

.stats-card .label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.stats-calendar {
    margin-bottom: 20px;
}

.stats-month-label {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.stats-day {
    aspect-ratio: 1;
    border-radius: 4px;
    background: var(--bg-input);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: var(--text-secondary);
    position: relative;
}

.stats-day.empty {
    background: transparent;
}

.stats-day.has-data {
    background: var(--primary);
    opacity: 0.3;
}

.stats-day.rate-50 { opacity: 0.5; }
.stats-day.rate-75 { opacity: 0.75; }
.stats-day.rate-100 { opacity: 1; background: var(--success); }

.stats-day.today {
    border: 2px solid var(--primary);
}

.stats-list {
    max-height: 200px;
    overflow-y: auto;
}

.stats-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: var(--bg-input);
    border-radius: 8px;
    margin-bottom: 8px;
}

.stats-item .date {
    font-size: 14px;
    color: var(--text-secondary);
}

.stats-item .result {
    font-size: 14px;
    font-weight: 600;
}

.stats-item .result.perfect {
    color: var(--success);
}

.stats-item .progress-bar {
    flex: 1;
    height: 6px;
    background: var(--bg);
    border-radius: 3px;
    margin: 0 12px;
    overflow: hidden;
}

.stats-item .progress-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 3px;
    transition: width 0.3s;
}

.stats-item .progress-fill.perfect {
    background: var(--success);
}

.stats-empty {
    text-align: center;
    color: var(--text-secondary);
    padding: 40px 20px;
}

/* 푸터 (언어 선택) */
.app-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 12px;
    text-align: center;
    background: linear-gradient(transparent, var(--bg) 30%);
    pointer-events: none;
}

.lang-switch {
    pointer-events: auto;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-card);
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid var(--border);
}

.lang-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 12px;
    transition: all 0.2s;
}

.lang-btn:hover {
    color: var(--text);
}

.lang-btn.active {
    color: var(--primary);
    font-weight: 600;
}

.lang-divider {
    color: var(--border);
    font-size: 12px;
}

/* 반응형 */
@media (max-width: 400px) {
    .app {
        padding: 12px;
    }

    .header h1 {
        font-size: 20px;
    }

    .add-todo {
        flex-direction: column;
    }

    .add-todo .btn-primary {
        width: 100%;
    }
}
