/* ===== Password Screen ===== */
.password-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #0e2f44, #1a5276);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.password-overlay.hidden {
    display: none;
}

.password-box {
    background: white;
    border-radius: 16px;
    padding: 48px 40px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    max-width: 400px;
    width: 90%;
}

.password-icon {
    font-size: 3rem;
    margin-bottom: 16px;
}

.password-box h2 {
    font-size: 1.2rem;
    color: #2c3e50;
    margin-bottom: 24px;
    font-weight: 700;
}

.password-field {
    width: 100%;
    padding: 14px 18px;
    border: 2px solid #dfe6e9;
    border-radius: 10px;
    font-family: inherit;
    font-size: 1rem;
    text-align: center;
    margin-bottom: 16px;
    transition: 0.3s ease;
}

.password-field:focus {
    outline: none;
    border-color: #2980b9;
    box-shadow: 0 0 0 3px rgba(41,128,185,0.15);
}

.password-submit {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #1a5276, #2980b9);
    color: white;
    border: none;
    border-radius: 10px;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: 0.3s ease;
}

.password-submit:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.password-error {
    color: #e74c3c;
    font-size: 0.85rem;
    margin-top: 12px;
    display: none;
}

.password-error.show {
    display: block;
    animation: shake 0.4s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-8px); }
    75% { transform: translateX(8px); }
}

.app-content.locked {
    display: none;
}

/* ===== Reset & Base ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #1a5276;
    --primary-light: #2980b9;
    --primary-dark: #0e2f44;
    --accent: #e67e22;
    --accent-light: #f39c12;
    --success: #27ae60;
    --danger: #e74c3c;
    --bg: #f5f6fa;
    --bg-card: #ffffff;
    --text: #2c3e50;
    --text-light: #7f8c8d;
    --border: #dfe6e9;
    --shadow: 0 2px 10px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: 0.3s ease;
}

body {
    font-family: 'Noto Sans JP', 'Zen Kaku Gothic New', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.7;
    min-height: 100vh;
}

/* ===== Header ===== */
.header {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    color: white;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 20px rgba(0,0,0,0.15);
}

.header-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.1rem;
    font-weight: 700;
    white-space: nowrap;
}

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

.logo-sub {
    font-size: 0.7rem;
    font-weight: 400;
    opacity: 0.8;
    background: rgba(255,255,255,0.15);
    padding: 2px 8px;
    border-radius: 4px;
}

.nav {
    display: flex;
    gap: 4px;
}

.nav-btn {
    background: transparent;
    border: none;
    color: rgba(255,255,255,0.7);
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.9rem;
    font-family: inherit;
    transition: var(--transition);
    white-space: nowrap;
}

.nav-btn:hover {
    background: rgba(255,255,255,0.1);
    color: white;
}

.nav-btn.active {
    background: rgba(255,255,255,0.2);
    color: white;
    font-weight: 500;
}

.menu-toggle {
    display: none;
    background: transparent;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 8px;
}

.mobile-nav {
    display: none;
    background: var(--primary-dark);
    padding: 8px 16px 16px;
    flex-direction: column;
    gap: 4px;
}

.mobile-nav.show {
    display: flex;
}

.mobile-nav .nav-btn {
    text-align: left;
    padding: 12px 16px;
}

/* ===== Main ===== */
.main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 16px 80px;
}

.page {
    display: none;
}

.page.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

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

.page-header {
    margin-bottom: 32px;
}

.page-header h2 {
    font-size: 1.8rem;
    font-weight: 900;
    color: var(--primary-dark);
    margin-bottom: 4px;
}

.page-desc {
    color: var(--text-light);
    font-size: 0.95rem;
}

/* ===== Forms ===== */
.form-section {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--primary-light);
}

.section-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.section-num {
    background: var(--primary);
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.section-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary-dark);
}

.form-group {
    margin-bottom: 16px;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-light);
    margin-bottom: 6px;
}

.form-input {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--text);
    transition: var(--transition);
    background: white;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(41,128,185,0.1);
}

.form-textarea {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--text);
    resize: vertical;
    transition: var(--transition);
    line-height: 1.6;
    background: white;
}

.form-textarea:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(41,128,185,0.1);
}

.form-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

/* ===== Milestone ===== */
.milestone-item {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 10px;
}

.milestone-date {
    width: 180px;
    flex-shrink: 0;
}

.milestone-text {
    flex: 1;
}

.milestone-check {
    position: relative;
    cursor: pointer;
}

.milestone-check input {
    display: none;
}

.milestone-check .checkmark {
    width: 32px;
    height: 32px;
    border: 2px solid var(--border);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: transparent;
    transition: var(--transition);
    font-size: 1rem;
}

.milestone-check input:checked + .checkmark {
    background: var(--success);
    border-color: var(--success);
    color: white;
}

.btn-add {
    background: transparent;
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 20px;
    color: var(--text-light);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9rem;
    transition: var(--transition);
    width: 100%;
    margin-top: 8px;
}

.btn-add:hover {
    border-color: var(--primary-light);
    color: var(--primary-light);
    background: rgba(41,128,185,0.05);
}

/* ===== Open Window 64 (Mandala Chart) ===== */
.ow64-container {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}

.ow64-instructions {
    background: #eaf2f8;
    border-radius: var(--radius-sm);
    padding: 14px 18px;
    margin-bottom: 24px;
    font-size: 0.9rem;
    color: var(--primary-dark);
}

.mandala-grid {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    gap: 3px;
    margin-bottom: 20px;
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
}

.mandala-cell {
    position: relative;
}

.mandala-cell textarea {
    width: 100%;
    height: 100%;
    min-height: 60px;
    padding: 6px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-family: inherit;
    font-size: 0.7rem;
    line-height: 1.3;
    resize: none;
    text-align: center;
    transition: var(--transition);
    background: white;
    color: var(--text);
}

.mandala-cell textarea:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 2px rgba(41,128,185,0.15);
    z-index: 1;
}

.mandala-cell.center textarea {
    background: var(--accent);
    color: white;
    font-weight: 700;
    font-size: 0.8rem;
    border-color: var(--accent);
}

.mandala-cell.center textarea::placeholder {
    color: rgba(255,255,255,0.7);
}

.mandala-cell.base textarea {
    background: #eaf2f8;
    font-weight: 500;
    border-color: var(--primary-light);
}

.mandala-cell.base textarea::placeholder {
    color: var(--primary-light);
}

/* Separators between 3x3 blocks */
.mandala-cell[data-col="2"] textarea { border-right: 3px solid var(--primary-light); }
.mandala-cell[data-col="5"] textarea { border-right: 3px solid var(--primary-light); }
.mandala-cell[data-row="2"] textarea { border-bottom: 3px solid var(--primary-light); }
.mandala-cell[data-row="5"] textarea { border-bottom: 3px solid var(--primary-light); }

.ow64-legend {
    display: flex;
    gap: 24px;
    justify-content: center;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-light);
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 4px;
}

.legend-color.center { background: var(--accent); }
.legend-color.base { background: #eaf2f8; border: 1px solid var(--primary-light); }
.legend-color.action { background: white; border: 1px solid var(--border); }

/* ===== Routine ===== */
.routine-container {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}

.routine-period {
    margin-bottom: 24px;
}

.routine-period .form-group {
    max-width: 250px;
}

.routine-setup {
    margin-bottom: 32px;
}

.routine-setup h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary-dark);
    margin-bottom: 16px;
}

.routine-categories {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.routine-category {
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 16px;
}

.routine-category h4 {
    font-size: 0.95rem;
    margin-bottom: 12px;
    color: var(--primary-dark);
}

.routine-item-input {
    margin-bottom: 8px;
}

.routine-item-input .form-input {
    font-size: 0.85rem;
    padding: 8px 12px;
}

.btn-add-routine {
    border: 1px dashed var(--border);
    padding: 6px;
    font-size: 0.8rem;
}

.routine-table-wrapper {
    overflow-x: auto;
    margin-bottom: 24px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.routine-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
    min-width: 800px;
}

.routine-table th,
.routine-table td {
    padding: 6px 4px;
    text-align: center;
    border: 1px solid var(--border);
}

.routine-table thead th {
    background: var(--primary);
    color: white;
    font-weight: 500;
    position: sticky;
    top: 0;
}

.routine-table thead th.day-sun { background: #c0392b; }
.routine-table thead th.day-sat { background: #2471a3; }

.routine-table tbody td:first-child {
    text-align: left;
    padding-left: 10px;
    font-weight: 500;
    white-space: nowrap;
    min-width: 140px;
    background: #fafafa;
}

.routine-table .check-cell {
    cursor: pointer;
    width: 28px;
    height: 28px;
    transition: var(--transition);
}

.routine-table .check-cell:hover {
    background: #eaf2f8;
}

.routine-table .check-cell.checked {
    background: var(--success);
    color: white;
}

.routine-table .check-cell.checked::after {
    content: '○';
    font-weight: 700;
}

.routine-stats {
    display: flex;
    gap: 20px;
    justify-content: center;
}

.stat-card {
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 20px 32px;
    text-align: center;
}

.stat-value {
    font-size: 2rem;
    font-weight: 900;
    color: var(--primary);
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-top: 4px;
}

/* ===== Journal ===== */
.journal-container {
    max-width: 800px;
    margin: 0 auto;
}

.journal-date-nav {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
    justify-content: center;
}

.journal-date-input {
    width: auto;
    font-size: 1.1rem;
    font-weight: 700;
    text-align: center;
}

.btn-icon {
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    font-size: 0.9rem;
}

.btn-icon:hover {
    border-color: var(--primary-light);
    color: var(--primary-light);
}

.btn-small {
    background: var(--primary-light);
    color: white;
    border: none;
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.8rem;
    transition: var(--transition);
}

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

.journal-section {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

.journal-section-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.journal-icon {
    font-size: 1.2rem;
}

.journal-section-header h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary-dark);
}

.rating-stars {
    display: flex;
    gap: 8px;
}

.star {
    background: none;
    border: none;
    font-size: 2rem;
    color: var(--border);
    cursor: pointer;
    transition: var(--transition);
    padding: 0;
    line-height: 1;
}

.star.active {
    color: var(--accent);
}

.star:hover {
    color: var(--accent-light);
    transform: scale(1.2);
}

.journal-history {
    margin-top: 40px;
}

.journal-history h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary-dark);
    margin-bottom: 16px;
}

.journal-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.journal-list-item {
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    padding: 14px 18px;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.journal-list-item:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-1px);
}

.journal-list-item .date {
    font-weight: 700;
    color: var(--primary);
}

.journal-list-item .stars {
    color: var(--accent);
}

.journal-list-item .preview {
    color: var(--text-light);
    font-size: 0.85rem;
    flex: 1;
    margin: 0 16px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ===== Save Toast ===== */
.save-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--success);
    color: white;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    font-size: 0.9rem;
    font-weight: 500;
    transform: translateY(100px);
    opacity: 0;
    transition: 0.4s ease;
    z-index: 200;
}

.save-toast.show {
    transform: translateY(0);
    opacity: 1;
}

/* ===== Footer ===== */
.footer {
    text-align: center;
    padding: 24px 16px;
    color: var(--text-light);
    font-size: 0.8rem;
    border-top: 1px solid var(--border);
    margin-top: 40px;
}

.footer-actions {
    margin-top: 12px;
    display: flex;
    gap: 12px;
    justify-content: center;
}

/* ===== Guidance Tips ===== */
.guidance-tip {
    background: linear-gradient(135deg, #fef9e7, #fdebd0);
    border: 1px solid #f0c27a;
    border-radius: var(--radius-sm);
    padding: 14px 18px;
    margin-bottom: 16px;
    font-size: 0.88rem;
    color: #7d6608;
    line-height: 1.6;
    position: relative;
}

.guidance-tip::before {
    content: '💡';
    margin-right: 8px;
}

.guidance-tip .tip-close {
    position: absolute;
    top: 8px;
    right: 10px;
    background: none;
    border: none;
    cursor: pointer;
    color: #b7950b;
    font-size: 1rem;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .nav { display: none; }
    .menu-toggle { display: block; }

    .header-inner { height: 56px; }

    .logo-sub { display: none; }

    .page-header h2 { font-size: 1.4rem; }

    .form-grid-2 {
        grid-template-columns: 1fr;
    }

    .milestone-item {
        flex-wrap: wrap;
    }

    .milestone-date {
        width: 100%;
    }

    .mandala-cell textarea {
        min-height: 45px;
        font-size: 0.55rem;
        padding: 3px;
    }

    .routine-stats {
        flex-direction: column;
        align-items: center;
    }

    .journal-list-item .preview {
        display: none;
    }
}

@media (max-width: 480px) {
    .main {
        padding: 16px 8px 80px;
    }

    .form-section {
        padding: 16px;
    }

    .ow64-container {
        padding: 12px;
    }

    .mandala-cell textarea {
        min-height: 38px;
        font-size: 0.5rem;
    }
}
