:root {
    --primary-color: #1890ff;
    --primary-hover: #40a9ff;
    --bg-color: #f0f2f5;
    --card-bg: #ffffff;
    --text-color: #262626;
    --text-muted: #8c8c8c;
    --border-radius: 12px;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Inter', 'Noto Sans JP', sans-serif; background-color: var(--bg-color); color: var(--text-color); line-height: 1.4; overflow-x: hidden; -webkit-text-size-adjust: 100%; }

/* Header */
.header-container {
    background: var(--card-bg);
    padding: 1rem 5%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    position: sticky;
    top: 0;
    z-index: 1000;
}
.logo-link { text-decoration: none; color: var(--primary-color); }
.logo-link h1 { font-size: 1.1rem; font-weight: 800; }
.header-right { display: flex; align-items: center; gap: 8px; }

/* Main Content */
.app-container { max-width: 1200px; margin: 15px auto; padding: 0 10px; }

/* Dashboard */
.dashboard-grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); 
    gap: 15px; 
    margin-bottom: 25px; 
}
.dash-card { background: var(--card-bg); border-radius: var(--border-radius); padding: 18px; box-shadow: var(--shadow); }
.dash-card-today { padding: 25px; background: linear-gradient(135deg, #40a9ff 0%, #1890ff 100%); color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,0.1); }
.dash-label { font-size: 0.75rem; font-weight: 800; color: var(--text-muted); margin-bottom: 12px; }
.dash-card-today .dash-label { color: rgba(255,255,255,0.9); }
.dash-date-text { font-size: 2.2rem; font-weight: 900; }
.stuff-item { background: #f9f9f9; padding: 8px 12px; border-radius: 8px; margin-bottom: 6px; font-size: 0.85rem; font-weight: 700; border-left: 3px solid var(--primary-color); display: flex; align-items: center; justify-content: space-between; }
.stuff-checkbox { width: 18px; height: 18px; cursor: pointer; accent-color: var(--primary-color); margin-right: 8px; }
.stuff-text { flex-grow: 1; }
.stuff-text.completed { text-decoration: line-through; color: #bfbfbf; }

/* Calendar */
.calendar-section { background: var(--card-bg); border-radius: var(--border-radius); padding: 15px; box-shadow: var(--shadow); }
.calendar-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; flex-wrap: wrap; gap: 10px; }
.calendar-header h2 { font-size: 1.2rem; font-weight: 900; }
.calendar-controls { display: flex; gap: 8px; background: #f5f5f5; padding: 4px; border-radius: 10px; }
.calendar-controls button { background: transparent; border: none; padding: 6px 12px; border-radius: 6px; font-weight: 700; cursor: pointer; transition: 0.2s; color: var(--text-muted); }
.calendar-controls button:hover { background: #e8e8e8; color: var(--text-color); }
.calendar-controls button#today-btn { background: #fff; box-shadow: 0 2px 4px rgba(0,0,0,0.05); color: var(--text-color); }
.calendar-legend { display: flex; flex-wrap: wrap; gap: 10px; font-size: 0.75rem; background: #fafafa; padding: 8px 12px; border-radius: 8px; }
.view-toggle { display: flex; background: #f5f5f5; border-radius: 10px; padding: 4px; }
.view-toggle button { background: transparent; border: none; padding: 6px 12px; font-size: 0.8rem; font-weight: 700; cursor: pointer; border-radius: 6px; color: var(--text-muted); transition: 0.2s; }
.view-toggle button.active { background: #fff; color: var(--text-color); box-shadow: 0 2px 4px rgba(0,0,0,0.05); }

/* Calendar Grid */
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; background-color: #eee; border: 1px solid #eee; border-radius: 8px; }
.calendar-day-header { background-color: #fafafa; padding: 8px 2px; text-align: center; font-size: 0.7rem; font-weight: 800; color: var(--text-muted); }
.calendar-day { background-color: #fff; min-height: 80px; padding: 5px; }
.day-number { font-size: 0.8rem; font-weight: 700; margin-bottom: 4px; display: inline-block; }
.sun-day, .sat-day { color: #ff4d4f !important; }

/* Timeline List View */
.timeline-list { display: none; flex-direction: column; gap: 15px; margin-top: 20px; }
.timeline-month-header { font-size: 1rem; font-weight: 800; border-bottom: 2px solid #f0f0f0; padding-bottom: 8px; margin-top: 15px; color: var(--primary-color); }
.timeline-item { display: flex; align-items: flex-start; gap: 15px; padding: 15px; background: #fafafa; border-radius: 12px; border-left: 4px solid var(--primary-color); }
.tl-date { min-width: 60px; text-align: center; }
.tl-day-num { font-size: 1.5rem; font-weight: 900; line-height: 1; }
.tl-day-name { font-size: 0.75rem; color: var(--text-muted); font-weight: 700; }
.tl-content { flex: 1; }
.tl-title { font-weight: 800; font-size: 1rem; display: flex; align-items: center; gap: 8px; margin-bottom: 5px; }
.tl-desc { font-size: 0.85rem; color: var(--text-muted); line-height: 1.5; white-space: pre-wrap; }

/* Event Items */
.event-item {
    font-size: 0.65rem;
    padding: 3px 5px;
    margin-bottom: 3px;
    border-radius: 4px;
    cursor: pointer;
    line-height: 1.2;
    word-break: break-all;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.category-submit { background: #e6f7ff; color: #1890ff; border-left: 3px solid #1890ff; }
.category-submit .tl-title { color: #1890ff; }
.category-test { background: #fff1f0; color: #ff4d4f; border-left: 3px solid #ff4d4f; }
.category-test .tl-title { color: #ff4d4f; }
.category-stuff { background: #f6ffed; color: #52c41a; border-left: 3px solid #52c41a; }
.category-stuff .tl-title { color: #52c41a; }
.category-event { background: #f9f0ff; color: #722ed1; border-left: 3px solid #722ed1; } /* 行事用 */
.category-event .tl-title { color: #722ed1; }
.category-other { background: #f5f5f5; color: #595959; border-left: 3px solid #d9d9d9; }

/* Modal Styles - Rewritten for Stability */
.modal { 
    position: fixed; inset: 0; background: rgba(0,0,0,0.6); 
    display: none; align-items: center; justify-content: center; 
    z-index: 2000; padding: 15px;
}
.modal-content { 
    background: #fff; border-radius: 16px; width: 100%; max-width: 500px; 
    max-height: 90vh; overflow-y: auto; position: relative;
    display: flex; flex-direction: column;
}
.modal-header { 
    padding: 20px 25px; border-bottom: 1px solid #eee; 
    display: flex; justify-content: space-between; align-items: center;
    position: sticky; top: 0; background: #fff; z-index: 5;
}
.modal-header h3 { font-size: 1.1rem; font-weight: 800; }
.form-body { padding: 25px; flex: 1; }
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 0.85rem; font-weight: 800; margin-bottom: 8px; color: var(--text-color); }
.form-row { display: flex; gap: 12px; margin-bottom: 18px; }
.form-row .form-group { flex: 1; margin-bottom: 0; }

.edit-input, .edit-textarea {
    width: 100%; padding: 12px; border: 1px solid #d9d9d9; border-radius: 8px; 
    font-size: 1rem; font-family: inherit; transition: border-color 0.2s;
}
.edit-input:focus, .edit-textarea:focus { border-color: var(--primary-color); outline: none; }
.edit-textarea { min-height: 120px; resize: vertical; line-height: 1.5; }

.modal-footer { 
    padding: 15px 25px; border-top: 1px solid #eee; 
    display: flex; justify-content: space-between; gap: 10px;
    background: #fff; position: sticky; bottom: 0;
}

.primary-btn { background: var(--primary-color); color: #fff; border: none; padding: 10px 20px; border-radius: 8px; font-weight: 700; cursor: pointer; }
.secondary-btn { background: #fff; color: var(--text-color); border: 1px solid #d9d9d9; padding: 10px 20px; border-radius: 8px; font-weight: 700; cursor: pointer; }

/* Responsive adjustments */
@media (max-width: 768px) {
    .modal-content { height: 100%; max-height: 100%; border-radius: 0; }
    .header-right span { display: none; }
    .form-row { flex-direction: column; gap: 18px; }
}

/* ========================================================
   Login Page Styles (Restored)
======================================================== */
.login-wrapper { display: flex; align-items: center; justify-content: center; min-height: 70vh; padding: 20px; }
.login-card { background: var(--card-bg); border-radius: 16px; padding: 40px 30px; box-shadow: var(--shadow); max-width: 400px; width: 100%; text-align: center; }
.login-icon { margin-bottom: 20px; color: var(--primary-color); display: flex; justify-content: center; }
.login-icon svg { width: 64px; height: 64px; stroke-width: 1.5; }
.login-title { font-size: 1.5rem; font-weight: 800; color: var(--text-color); margin-bottom: 10px; }
.login-subtitle { font-size: 0.9rem; color: var(--text-muted); line-height: 1.5; margin-bottom: 30px; }
.google-login-btn { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; background: #fff; border: 1px solid #d9d9d9; padding: 12px; border-radius: 8px; font-size: 1rem; font-weight: 700; color: var(--text-color); cursor: pointer; transition: 0.2s; box-shadow: 0 2px 4px rgba(0,0,0,0.02); }
.google-login-btn:hover { background: #fafafa; border-color: #bfbfbf; }
.google-login-btn img { width: 24px; height: 24px; }
.domain-notice { margin-top: 25px; font-size: 0.75rem; color: #ff4d4f; font-weight: 600; padding: 10px; background: #fff1f0; border-radius: 8px; border: 1px solid #ffa39e; }
#error-message { margin-top: 15px; color: #ff4d4f; font-size: 0.85rem; font-weight: 700; display: none; }

/* ========================================================
   Footer Styles (Restored)
======================================================== */
.footer { background: var(--card-bg); border-top: 1px solid #eee; padding: 40px 20px 20px; margin-top: 40px; }
.footer-container { max-width: 1200px; margin: 0 auto; }
.footer-top { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 30px; margin-bottom: 30px; }
.footer-brand h3 { font-size: 1.2rem; font-weight: 900; color: var(--text-color); }
.link-group h4 { font-size: 0.9rem; font-weight: 800; color: var(--text-color); margin-bottom: 15px; }
.link-group a { display: block; color: var(--text-muted); text-decoration: none; margin-bottom: 10px; font-size: 0.85rem; transition: 0.2s; }
.link-group a:hover { color: var(--primary-color); }
.footer-bottom { text-align: center; border-top: 1px solid #f0f0f0; padding-top: 20px; font-size: 0.75rem; color: var(--text-muted); font-weight: 600; }
