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

:root {
    --primary-color: #6c5ce7;
    --secondary-color: #a29bfe;
    --background-color: #f8f9fa;
    --card-background: #ffffff;
    --text-color: #2d3436;
    --text-light: #636e72;
    --border-radius: 16px;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    --shadow-hover: 0 8px 30px rgba(0, 0, 0, 0.12);
    --success-color: #00b894;
    --danger-color: #e74c3c;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: var(--text-color);
    line-height: 1.6;
}

.page {
    min-height: 100vh;
}

.hidden {
    display: none !important;
}

.auth-container {
    max-width: 400px;
    margin: 0 auto;
    padding: 40px 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.auth-header {
    text-align: center;
    margin-bottom: 30px;
    color: white;
}

.auth-header h1 {
    font-size: 2rem;
    margin-bottom: 10px;
}

.auth-header p {
    opacity: 0.9;
}

.auth-tabs {
    display: flex;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    padding: 4px;
    margin-bottom: 20px;
}

.auth-tab {
    flex: 1;
    padding: 12px;
    border: none;
    background: transparent;
    color: white;
    font-size: 1rem;
    cursor: pointer;
    border-radius: 10px;
    transition: all 0.3s ease;
}

.auth-tab.active {
    background: white;
    color: var(--primary-color);
    font-weight: 600;
}

.auth-form {
    background: var(--card-background);
    padding: 30px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-color);
}

.form-group input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.auth-btn {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.auth-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(108, 92, 231, 0.4);
}

.forgot-password-link {
    text-align: center;
    margin-top: 15px;
}

.forgot-password-link a {
    color: var(--primary-color);
    text-decoration: none;
    font-size: 0.9rem;
}

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

.code-input-group {
    display: flex;
    gap: 10px;
}

.code-input-group input {
    flex: 1;
}

.send-code-btn {
    padding: 12px 15px;
    background: var(--background-color);
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
    border-radius: 10px;
    font-size: 0.85rem;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.3s ease;
}

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

.send-code-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
}

header {
    color: white;
    margin-bottom: 20px;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.header-top h1 {
    font-size: 1.8rem;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 15px;
}

.nickname {
    font-weight: 500;
}

.logout-btn {
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 20px;
    color: white;
    cursor: pointer;
    transition: background 0.3s ease;
}

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

.nav-tabs {
    display: flex;
    gap: 10px;
    background: rgba(255, 255, 255, 0.1);
    padding: 5px;
    border-radius: 12px;
}

.nav-tab {
    flex: 1;
    padding: 12px 20px;
    border: none;
    background: transparent;
    color: white;
    font-size: 0.95rem;
    cursor: pointer;
    border-radius: 10px;
    transition: all 0.3s ease;
}

.nav-tab.active {
    background: white;
    color: var(--primary-color);
    font-weight: 600;
}

main {
    background: var(--card-background);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.content-section {
    padding: 30px;
}

.mood-input h2,
.mood-history h2,
.family-moods h2 {
    font-size: 1.4rem;
    margin-bottom: 20px;
    color: var(--text-color);
}

.mood-selector {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.mood-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 18px 12px;
    border: 2px solid transparent;
    border-radius: 12px;
    background: var(--background-color);
    cursor: pointer;
    transition: all 0.3s ease;
}

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

.mood-btn.selected {
    border-color: var(--primary-color);
    background: linear-gradient(135deg, #f5f3ff 0%, #ede9fe 100%);
    transform: scale(1.05);
}

.mood-btn .emoji {
    font-size: 2.2rem;
    margin-bottom: 6px;
}

.mood-btn .label {
    font-size: 0.85rem;
    color: var(--text-light);
    font-weight: 500;
}

.note-section {
    margin-bottom: 20px;
}

.note-section label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
}

.note-section textarea {
    width: 100%;
    min-height: 100px;
    padding: 12px;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    font-size: 1rem;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.3s ease;
}

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

.share-section {
    margin-bottom: 20px;
}

.share-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.share-label input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: var(--primary-color);
}

.share-text {
    font-weight: 500;
    color: var(--text-color);
}

.save-btn {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.save-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(108, 92, 231, 0.4);
}

.save-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.today-record-status {
    margin-top: 15px;
    padding: 15px;
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 10px;
    text-align: center;
}

.today-record-status .status-text {
    display: block;
    color: #856404;
    margin-bottom: 10px;
    font-weight: 500;
}

.edit-today-btn {
    padding: 8px 20px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 20px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.edit-today-btn:hover {
    background: var(--secondary-color);
    transform: translateY(-1px);
}

.mood-history,
.family-moods {
    margin-top: 30px;
    padding-top: 30px;
    border-top: 1px solid #e9ecef;
}

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

.stat-card {
    background: var(--background-color);
    padding: 15px;
    border-radius: 12px;
    text-align: center;
}

.stat-value {
    display: block;
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary-color);
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-light);
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 300px;
    overflow-y: auto;
}

.history-item {
    background: var(--background-color);
    padding: 15px;
    border-radius: 12px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.history-emoji {
    font-size: 1.8rem;
    flex-shrink: 0;
}

.history-content {
    flex: 1;
    min-width: 0;
}

.history-date {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-bottom: 3px;
}

.history-mood {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 3px;
}

.history-note {
    font-size: 0.9rem;
    color: var(--text-light);
    line-height: 1.4;
    word-break: break-word;
}

.history-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
}

.share-badge {
    font-size: 0.75rem;
    padding: 3px 8px;
    background: #d4edda;
    color: #155724;
    border-radius: 10px;
}

.history-delete {
    background: none;
    border: none;
    color: #adb5bd;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 5px;
    transition: color 0.3s ease;
}

.history-delete:hover {
    color: var(--danger-color);
}

.empty-state {
    text-align: center;
    padding: 30px;
    color: var(--text-light);
}

.empty-state .emoji {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.family-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}

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

.family-actions {
    display: flex;
    gap: 10px;
}

.action-btn {
    padding: 10px 20px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

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

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

.family-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.family-card {
    background: var(--background-color);
    border-radius: 12px;
    padding: 20px;
}

.family-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 15px;
}

.family-name {
    font-size: 1.2rem;
    font-weight: 600;
}

.family-id {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-top: 5px;
    font-family: monospace;
    background: white;
    padding: 4px 8px;
    border-radius: 4px;
    display: inline-block;
}

.family-role {
    font-size: 0.8rem;
    padding: 4px 10px;
    background: var(--primary-color);
    color: white;
    border-radius: 10px;
}

.family-members {
    margin-top: 15px;
}

.family-members h4 {
    font-size: 0.9rem;
    color: var(--text-light);
    margin-bottom: 10px;
}

.members-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.member-tag {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: white;
    border-radius: 20px;
    font-size: 0.9rem;
}

.member-tag.admin {
    border: 2px solid var(--primary-color);
}

.remove-member {
    background: none;
    border: none;
    color: #adb5bd;
    cursor: pointer;
    font-size: 1rem;
    padding: 0;
    line-height: 1;
}

.remove-member:hover {
    color: var(--danger-color);
}

.delete-family {
    background: none;
    border: none;
    font-size: 1rem;
    cursor: pointer;
    margin-left: 10px;
    padding: 5px;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.delete-family:hover {
    background: rgba(231, 76, 60, 0.1);
    color: var(--danger-color);
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 16px;
    width: 90%;
    max-width: 400px;
}

.modal-content h3 {
    margin-bottom: 20px;
    font-size: 1.3rem;
}

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.btn-primary,
.btn-secondary {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
}

.btn-secondary {
    background: #e9ecef;
    color: var(--text-color);
}

.report-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}

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

.month-selector {
    display: flex;
    align-items: center;
    gap: 15px;
}

.month-nav-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--background-color);
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.3s ease;
}

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

#current-month {
    font-size: 1.1rem;
    font-weight: 600;
    min-width: 120px;
    text-align: center;
}

.report-summary {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-bottom: 25px;
}

.report-card {
    background: var(--background-color);
    padding: 20px;
    border-radius: 12px;
    text-align: center;
}

.report-value {
    display: block;
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

.report-emoji {
    display: block;
    font-size: 3rem;
}

.report-label {
    font-size: 0.9rem;
    color: var(--text-light);
}

.mood-chart {
    background: var(--background-color);
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 25px;
}

.mood-chart h3 {
    font-size: 1.1rem;
    margin-bottom: 15px;
}

.chart-bars {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chart-bar-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chart-bar-emoji {
    font-size: 1.5rem;
    width: 35px;
    text-align: center;
}

.chart-bar-container {
    flex: 1;
    height: 24px;
    background: #e9ecef;
    border-radius: 12px;
    overflow: hidden;
}

.chart-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    border-radius: 12px;
    transition: width 0.5s ease;
}

.chart-bar-count {
    font-size: 0.9rem;
    font-weight: 600;
    min-width: 30px;
    text-align: right;
}

.suggestions {
    background: linear-gradient(135deg, #f5f3ff 0%, #ede9fe 100%);
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 25px;
}

.suggestions h3 {
    font-size: 1.1rem;
    margin-bottom: 15px;
    color: var(--primary-color);
}

.suggestions ul {
    list-style: none;
}

.suggestions li {
    padding: 10px 0;
    padding-left: 25px;
    position: relative;
    color: var(--text-color);
    line-height: 1.5;
}

.suggestions li::before {
    content: '💡';
    position: absolute;
    left: 0;
}

.family-comparison {
    background: var(--background-color);
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 25px;
}

.family-comparison h3 {
    font-size: 1.1rem;
    margin-bottom: 15px;
}

.comparison-content {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

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

.comparison-member {
    background: white;
    padding: 15px;
    border-radius: 10px;
}

.comparison-member-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.comparison-member-name {
    font-weight: 600;
}

.comparison-member-days {
    font-size: 0.85rem;
    color: var(--text-light);
}

.comparison-bars {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.comparison-bar-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.comparison-bar-emoji {
    font-size: 1.2rem;
    width: 30px;
    text-align: center;
}

.comparison-bar-track {
    flex: 1;
    height: 16px;
    background: #e9ecef;
    border-radius: 8px;
    overflow: hidden;
}

.comparison-bar-fill {
    height: 100%;
    border-radius: 8px;
    transition: width 0.5s ease;
}

.comparison-bar-fill.happy,
.comparison-bar-fill.calm {
    background: linear-gradient(90deg, #00b894, #55efc4);
}

.comparison-bar-fill.sad,
.comparison-bar-fill.anxious {
    background: linear-gradient(90deg, #6c5ce7, #a29bfe);
}

.comparison-bar-fill.angry {
    background: linear-gradient(90deg, #e74c3c, #ff7675);
}

.comparison-bar-fill.tired {
    background: linear-gradient(90deg, #fdcb6e, #ffeaa7);
}

.comparison-bar-count {
    font-size: 0.8rem;
    min-width: 25px;
    text-align: right;
    color: var(--text-light);
}

.comparison-summary {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #e9ecef;
}

.comparison-summary-title {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 10px;
}

.comparison-insight {
    font-size: 0.9rem;
    color: var(--text-light);
    line-height: 1.5;
}

.monthly-calendar h3 {
    font-size: 1.1rem;
    margin-bottom: 15px;
}

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

.calendar-day {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--background-color);
    border-radius: 8px;
    font-size: 1.2rem;
}

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

.calendar-day.has-mood {
    cursor: pointer;
    transition: transform 0.2s ease;
}

.calendar-day.has-mood:hover {
    transform: scale(1.1);
}

footer {
    text-align: center;
    padding: 20px;
    color: white;
    opacity: 0.8;
}

.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--text-color);
    color: white;
    padding: 15px 30px;
    border-radius: 30px;
    font-weight: 500;
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1001;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

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

.toast.success {
    background: var(--success-color);
}

@media (max-width: 600px) {
    .container {
        padding: 10px;
    }

    .header-top {
        flex-direction: column;
        gap: 15px;
    }

    .header-top h1 {
        font-size: 1.5rem;
    }

    .nav-tabs {
        flex-wrap: wrap;
    }

    .nav-tab {
        padding: 10px 15px;
        font-size: 0.85rem;
    }

    .mood-selector {
        grid-template-columns: repeat(2, 1fr);
    }

    .stats {
        grid-template-columns: repeat(3, 1fr);
    }

    .content-section {
        padding: 20px;
    }

    .family-header {
        flex-direction: column;
        gap: 15px;
    }

    .report-summary {
        grid-template-columns: 1fr;
    }
}
