/* 메모장 앱 스타일 */
:root {
    --primary-color: #6C5CE7;
    --primary-light: #A29BFE;
    --primary-dark: #5849C2;
    --secondary-color: #00CEC9;
    --background-color: #F8F9FA;
    --card-color: #FFFFFF;
    --text-color: #2D3436;
    --text-secondary: #636E72;
    --text-muted: #B2BEC3;
    --border-color: #DFE6E9;
    --danger-color: #FF7675;
    --success-color: #00B894;
    --warning-color: #FDCB6E;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* 화면 컨테이너 */
.screen {
    min-height: 100vh;
    min-height: 100dvh;
}

.hidden {
    display: none !important;
}

/* ===== 로그인 화면 ===== */
.login-container {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
}

.login-header {
    text-align: center;
    color: white;
    margin-bottom: 3rem;
}

.app-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

.login-header h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.login-subtitle {
    font-size: 1rem;
    opacity: 0.9;
}

.user-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
    max-width: 280px;
}

.user-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 1rem 2rem;
    background: white;
    border: none;
    border-radius: var(--radius-lg);
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--primary-color);
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-md);
}

.user-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

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

.user-btn .emoji {
    font-size: 1.5rem;
}

/* 로그인 폼 */
.login-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
    max-width: 320px;
}

.login-input {
    padding: 1rem 1.25rem;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.95);
    font-size: 1rem;
    color: var(--text-color);
    transition: all 0.2s;
}

.login-input:focus {
    outline: none;
    border-color: white;
    background: white;
}

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

.login-btn {
    padding: 1rem 1.25rem;
    background: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--primary-color);
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: var(--shadow-md);
}

.login-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

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

/* ===== 앱 헤더 ===== */
.app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    background: var(--primary-color);
    color: white;
    box-shadow: var(--shadow-sm);
}

.user-name {
    font-weight: 600;
    font-size: 1.125rem;
}

.logout-btn {
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: var(--radius-sm);
    color: white;
    font-size: 0.875rem;
    cursor: pointer;
    transition: background 0.2s;
}

.logout-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ===== 메인 컨텐츠 ===== */
.main-content {
    padding: 1rem;
    padding-bottom: calc(80px + env(safe-area-inset-bottom));
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== 메모 입력 섹션 ===== */
.memo-input-section {
    background: var(--card-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.input-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.input-icon {
    font-size: 1.25rem;
}

.input-wrapper {
    position: relative;
    margin-bottom: 1rem;
}

.memo-textarea {
    width: 100%;
    min-height: 100px;
    padding: 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-family: inherit;
    resize: none;
    transition: border-color 0.2s;
}

.memo-textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.memo-textarea::placeholder {
    color: var(--text-muted);
}

.char-count {
    position: absolute;
    bottom: 0.75rem;
    right: 0.75rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.input-actions {
    display: flex;
    gap: 0.75rem;
}

.voice-btn,
.save-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1rem;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

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

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

.voice-btn.recording {
    background: var(--danger-color);
    color: white;
    animation: pulse 1s ease infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }
}

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

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

.save-btn:disabled {
    background: var(--text-muted);
    cursor: not-allowed;
}

/* 음성 인식 상태 */
.voice-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-top: 1rem;
    padding: 1rem;
    background: var(--primary-light);
    border-radius: var(--radius-md);
    color: white;
}

.voice-wave {
    display: flex;
    align-items: center;
    gap: 3px;
    height: 24px;
}

.voice-wave span {
    width: 4px;
    height: 100%;
    background: white;
    border-radius: 2px;
    animation: wave 0.6s ease-in-out infinite;
}

.voice-wave span:nth-child(1) {
    animation-delay: 0s;
}

.voice-wave span:nth-child(2) {
    animation-delay: 0.1s;
}

.voice-wave span:nth-child(3) {
    animation-delay: 0.2s;
}

.voice-wave span:nth-child(4) {
    animation-delay: 0.3s;
}

.voice-wave span:nth-child(5) {
    animation-delay: 0.4s;
}

@keyframes wave {

    0%,
    100% {
        transform: scaleY(0.4);
    }

    50% {
        transform: scaleY(1);
    }
}

/* ===== 메모 목록 섹션 ===== */
.memo-list-section {
    background: var(--card-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
}

.section-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    font-weight: 600;
    color: var(--text-color);
}

.section-icon {
    font-size: 1.125rem;
}

.memo-count {
    margin-left: auto;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
}

.memo-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.memo-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem;
    background: var(--background-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s;
}

.memo-item:hover {
    background: var(--border-color);
}

.memo-item:active {
    transform: scale(0.98);
}

.memo-type-icon {
    font-size: 1rem;
    opacity: 0.7;
}

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

.memo-content {
    font-size: 0.9375rem;
    color: var(--text-color);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}

.memo-date {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.375rem;
}

.memo-list-empty {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
}

.empty-icon-small {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

/* ===== AI 정리 탭 ===== */
.ai-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.ai-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.125rem;
    font-weight: 600;
}

.ai-icon {
    font-size: 1.25rem;
}

.refresh-btn {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 1rem;
    background: var(--primary-color);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

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

.refresh-btn.spinning span:first-child {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.summary-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.summary-card {
    background: var(--card-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: all 0.2s;
}

.summary-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.summary-card:active {
    transform: translateY(0);
}

.summary-topic {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.summary-topic .topic-icon {
    font-size: 1.125rem;
}

.summary-topic .memo-count-badge {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-left: auto;
}

.summary-preview {
    font-size: 0.875rem;
    color: var(--text-secondary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.empty-state p {
    margin-bottom: 0.5rem;
}

.empty-hint {
    font-size: 0.875rem;
    opacity: 0.8;
}

/* ===== 하단 네비게이션 ===== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    background: var(--card-color);
    border-top: 1px solid var(--border-color);
    padding-bottom: env(safe-area-inset-bottom);
    z-index: 100;
}

.nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.75rem;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.75rem;
    cursor: pointer;
    transition: color 0.2s;
}

.nav-btn.active {
    color: var(--primary-color);
}

.nav-icon {
    font-size: 1.5rem;
}

.nav-label {
    font-weight: 500;
}

/* ===== 토스트 메시지 ===== */
.toast {
    position: fixed;
    bottom: calc(80px + env(safe-area-inset-bottom) + 1rem);
    left: 50%;
    transform: translateX(-50%);
    padding: 0.875rem 1.5rem;
    background: var(--text-color);
    color: white;
    border-radius: var(--radius-xl);
    font-size: 0.9375rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    animation: toastIn 0.3s ease;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* ===== 모달 ===== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 200;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.2s ease;
}

.modal-content {
    position: relative;
    width: 100%;
    max-width: 500px;
    max-height: 80vh;
    background: var(--card-color);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    animation: slideUp 0.3s ease;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }

    to {
        transform: translateY(0);
    }
}

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

.modal-date,
.modal-topic {
    font-weight: 600;
    color: var(--text-color);
}

.modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--background-color);
    border: none;
    border-radius: 50%;
    font-size: 1rem;
    color: var(--text-secondary);
    cursor: pointer;
}

.modal-body {
    padding: 1.25rem;
    overflow-y: auto;
    flex: 1;
}

.modal-memo-content {
    font-size: 1rem;
    line-height: 1.6;
    color: var(--text-color);
    white-space: pre-wrap;
    word-break: break-word;
}

.modal-footer {
    padding: 1rem 1.25rem;
    padding-bottom: calc(1rem + env(safe-area-inset-bottom));
    border-top: 1px solid var(--border-color);
}

.modal-delete-btn {
    width: 100%;
    padding: 0.875rem;
    background: var(--danger-color);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.modal-delete-btn:hover {
    background: #e66767;
}

/* 요약 모달 */
.summary-modal .modal-body {
    padding-bottom: calc(1.25rem + env(safe-area-inset-bottom));
}

.summary-content {
    font-size: 1rem;
    line-height: 1.7;
    color: var(--text-color);
    margin-bottom: 1.5rem;
    white-space: pre-wrap;
}

.related-memos {
    border-top: 1px solid var(--border-color);
    padding-top: 1rem;
}

.related-header {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

.related-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.related-memo-item {
    padding: 0.75rem;
    background: var(--background-color);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    color: var(--text-secondary);
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ===== 반응형 ===== */
@media (min-width: 768px) {
    .main-content {
        max-width: 600px;
        margin: 0 auto;
    }

    .modal-content {
        border-radius: var(--radius-xl);
        margin: auto;
        max-height: 70vh;
    }
}