@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@600;700&family=Noto+Sans+JP:wght@300;400;500;600&display=swap');

:root {
    --bg-primary: #0a0e27;
    --bg-secondary: #151932;
    --bg-card: #1a1f3a;
    --border-color: #2d3561;
    --accent-primary: #6366f1;
    --accent-glow: rgba(99, 102, 241, 0.3);
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --success: #10b981;
    --danger: #ef4444;
    --moon: #fbbf24;
}

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

body {
    background: linear-gradient(135deg, var(--bg-primary) 0%, #0f1729 100%);
    color: var(--text-primary);
    font-family: 'Noto Sans JP', sans-serif;
    font-weight: 300;
    line-height: 1.7;
    min-height: 100vh;
}

.app-container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* Header */
header {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1.5rem 0 2.5rem;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 2.5rem;
    position: relative; /* ログアウトボタン配置用 */
}

header h1 {
    font-family: 'Playfair Display', serif;
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--moon) 0%, #fcd34d 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 0.02em;
}

/* ログアウトボタン */
.logout-btn {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    text-decoration: none;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.logout-btn:hover {
    border-color: var(--accent-primary);
    color: var(--text-primary);
}

/* Card */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.75rem;
    margin-bottom: 1.5rem;
    backdrop-filter: blur(10px);
}

/* Login / Register Styles (Added) */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.auth-card {
    background: var(--bg-card);
    padding: 40px 30px;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    border: 1px solid var(--border-color);
    width: 100%;
    max-width: 450px;
    animation: slideUp 0.5s ease-out;
}

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

.auth-card h1 {
    font-family: 'Playfair Display', serif;
    font-size: 2rem;
    margin-bottom: 2rem;
    text-align: center;
    color: var(--text-primary);
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.auth-input {
    width: 100%;
    padding: 14px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 1rem;
    transition: all 0.3s ease;
}

.auth-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.auth-btn {
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, var(--accent-primary) 0%, #4f46e5 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 1rem;
}

.auth-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--accent-glow);
}

.auth-link {
    text-align: center;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.auth-link a {
    color: var(--accent-primary);
    text-decoration: none;
    font-weight: 500;
    margin-left: 0.5rem;
}

.auth-link a:hover {
    text-decoration: underline;
}

.flash-message {
    padding: 1rem;
    margin-bottom: 1.5rem;
    border-radius: 10px;
    text-align: center;
    font-size: 0.9rem;
}
.flash-message.error {
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.3);
}
.flash-message.success {
    background: rgba(16, 185, 129, 0.15);
    color: #6ee7b7;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

/* Calendar & Other Styles (Existing) */
.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.calendar-header button {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.6rem 1.2rem;
    border-radius: 10px;
    cursor: pointer;
    font-size: 1.1rem;
    transition: all 0.2s;
}

.calendar-header button:hover {
    background: var(--bg-card);
    transform: scale(1.05);
}

.calendar-header h2 {
    font-family: 'Playfair Display', serif;
    font-size: 1.5rem;
    font-weight: 600;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
    margin-bottom: 2.5rem;
}

.calendar-header-day {
    text-align: center;
    font-weight: 500;
    padding: 0.75rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    letter-spacing: 0.05em;
}

.calendar-day {
    aspect-ratio: 1;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.25s ease;
    position: relative;
    min-height: 60px;
}

.calendar-day:hover:not(.empty) {
    background: var(--bg-card);
    border-color: var(--accent-primary);
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

.calendar-day.empty {
    background: transparent;
    border-color: transparent;
    cursor: default;
}

.calendar-day.today {
    border-color: var(--moon);
    box-shadow: 0 0 12px var(--moon);
}

.calendar-day.has-entry {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.15) 0%, rgba(79, 70, 229, 0.1) 100%);
    border-color: var(--accent-primary);
}

.day-number {
    font-weight: 500;
    font-size: 1.05rem;
}

.day-indicator {
    font-size: 1.3rem;
    margin-top: 2px;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-3px); }
}

/* Today's Entry Card */
.today-card {
    background: linear-gradient(135deg, var(--bg-card) 0%, #1e2447 100%);
    border-color: var(--accent-primary);
}

.today-card h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
    color: var(--moon);
}

.today-dream {
    margin-bottom: 1.5rem;
}

.today-title {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

.today-preview {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.7;
}

.today-interpretation {
    background: rgba(99, 102, 241, 0.08);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 12px;
    padding: 1.25rem;
    margin: 1.25rem 0;
}

.interp-badge {
    display: inline-block;
    background: linear-gradient(135deg, var(--accent-primary) 0%, #4f46e5 100%);
    color: white;
    padding: 0.4rem 0.9rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    margin-bottom: 0.85rem;
}

.interp-message {
    color: var(--text-primary);
    font-size: 0.95rem;
    line-height: 1.7;
    margin-bottom: 0.75rem;
}

.today-lucky {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.15) 0%, rgba(5, 150, 105, 0.1) 100%);
    border: 1px solid rgba(16, 185, 129, 0.3);
    padding: 0.85rem;
    border-radius: 10px;
    font-size: 0.9rem;
    color: var(--text-primary);
    margin-top: 0.85rem;
}

.today-no-interp {
    color: var(--text-muted);
    font-size: 0.9rem;
    font-style: italic;
}

.no-entry {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 1rem;
}

.btn-small {
    background: var(--accent-primary);
    color: white;
    border: none;
    padding: 0.65rem 1.25rem;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.3s ease;
    display: inline-block;
    margin-top: 0.75rem;
}

.btn-small:hover {
    background: #4f46e5;
    transform: translateY(-2px);
}

/* Form */
.form-card h2 {
    font-family: 'Playfair Display', serif;
    font-size: 1.6rem;
    font-weight: 600;
    margin-bottom: 1.75rem;
}

.input-field {
    width: 100%;
    padding: 0.9rem 1.1rem;
    margin-bottom: 1.1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 10px;
    font-size: 0.95rem;
    font-family: 'Noto Sans JP', sans-serif;
    transition: all 0.2s;
}

.input-field:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

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

textarea.input-field {
    resize: vertical;
    min-height: 140px;
    line-height: 1.7;
}

.row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.1rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary) 0%, #4f46e5 100%);
    color: white;
    border: none;
    padding: 1rem 1.5rem;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 500;
    width: 100%;
    font-size: 0.95rem;
    margin-bottom: 0.85rem;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px var(--accent-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--accent-glow);
}

.btn-secondary {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    padding: 0.9rem 1.4rem;
    border-radius: 12px;
    cursor: pointer;
    width: 100%;
    font-size: 0.95rem;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-color: var(--accent-primary);
}

/* Detail */
.detail-card {
    margin-bottom: 1.5rem;
}

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

.detail-header h2 {
    font-family: 'Playfair Display', serif;
    font-size: 1.8rem;
    font-weight: 600;
}

.detail-header span {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.detail-meta {
    display: flex;
    gap: 0.85rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

.meta-tag {
    background: rgba(99, 102, 241, 0.12);
    border: 1px solid rgba(99, 102, 241, 0.3);
    color: var(--accent-primary);
    padding: 0.45rem 1rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
}

.content {
    line-height: 1.85;
    margin: 1.75rem 0;
    white-space: pre-wrap;
    font-size: 1rem;
    color: var(--text-secondary);
}

.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    margin: 1.25rem 0;
}

.tag {
    background: rgba(251, 191, 36, 0.12);
    color: var(--moon);
    padding: 0.45rem 1rem;
    border-radius: 20px;
    font-size: 0.85rem;
}

/* Actions */
.detail-actions {
    display: grid;
    grid-template-columns: 1fr 1fr 2fr;
    gap: 0.85rem;
    margin-top: 1.5rem;
}

.btn-edit, .btn-delete {
    padding: 0.85rem 1.1rem;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.3s;
}

.btn-edit {
    background: rgba(99, 102, 241, 0.12);
    border: 1px solid var(--accent-primary);
    color: var(--accent-primary);
}

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

.btn-delete {
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid var(--danger);
    color: var(--danger);
}

.btn-delete:hover {
    background: var(--danger);
    color: white;
}

/* Interpretation */
.interpretation-result {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.08) 0%, rgba(79, 70, 229, 0.05) 100%);
    border: 1px solid rgba(99, 102, 241, 0.2);
    padding: 1.75rem;
    border-radius: 14px;
    margin-top: 1.75rem;
}

.interpretation-result h3 {
    font-family: 'Playfair Display', serif;
    font-size: 1.4rem;
    font-weight: 600;
    margin-bottom: 1.75rem;
    color: var(--moon);
}

.interpretation-section {
    margin: 1.5rem 0;
}

.interpretation-section h4 {
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 0.85rem;
    color: var(--text-primary);
}

.interpretation-section p {
    line-height: 1.85;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.symbols {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.symbol-item {
    background: rgba(99, 102, 241, 0.08);
    padding: 1rem;
    border-radius: 10px;
    border-left: 3px solid var(--accent-primary);
    font-size: 0.95rem;
}

.symbol-item strong {
    color: var(--accent-primary);
    font-weight: 600;
}

.lucky-action {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.15) 0%, rgba(5, 150, 105, 0.1) 100%);
    border: 1px solid rgba(16, 185, 129, 0.3);
    padding: 1.25rem;
    border-radius: 12px;
    margin-top: 1.5rem;
    text-align: center;
    font-weight: 500;
    font-size: 0.95rem;
}

.loading, .error {
    text-align: center;
    padding: 1.5rem;
    font-size: 0.95rem;
}

.loading {
    color: var(--text-muted);
}

.error {
    color: var(--danger);
}

.hidden {
    display: none !important;
}

/* Responsive */
@media (max-width: 768px) {
    .app-container {
        padding: 1rem;
    }
    
    header h1 {
        font-size: 1.6rem;
    }
    
    .calendar-grid {
        gap: 4px;
    }
    
    .calendar-day {
        font-size: 0.85rem;
    }
    
    .row, .detail-actions {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .app-container {
        padding: 0.75rem;
    }

    header {
        margin-bottom: 1.5rem;
    }

    .card {
        padding: 1.25rem;
    }

    .calendar-day {
        min-height: 50px;
    }

    .day-number {
        font-size: 0.9rem;
    }

    .day-indicator {
        font-size: 1.1rem;
    }

    .form-card h2, .detail-header h2 {
        font-size: 1.4rem;
    }
    
    button {
        min-height: 44px;
    }
    
    .logout-btn {
        top: 1.5rem;
        right: 0;
        transform: none;
        padding: 0.4rem 0.8rem;
        font-size: 0.75rem;
    }
}