:root {
    --primary-color: #4899D8;
    --primary-dark: #3780B9;
    --primary-light: #7AB6E5;
    --primary-lightest: #E5F1FA;
    --secondary-color: #f8fafc;
    --border-color: #e2e8f0;
    --text-color: #1e293b;
    --text-light: #64748b;
    --cell-highlight: #f1f5f9;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

body {
    color: var(--text-color);
    background-color: #f1f5f9;
    line-height: 1.5;
}

/* トップバー */
.topbar {
    background-color: var(--primary-color);
    color: white;
    padding: 0.5rem 1rem;
    display: flex;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.menu-button {
    background: none;
    border: none;
    color: white;
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.25rem;
    margin-right: 1rem;
}

.menu-button a {
    color: inherit;
}

.topbar-title {
    font-size: 1.25rem;
    font-weight: bold;
    flex-grow: 1;
    text-align: center;
}

/* サイドメニュー */
.sidemenu {
    position: fixed;
    top: 0;
    left: -250px;
    width: 250px;
    height: 100%;
    background-color: white;
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1);
    z-index: 200;
    transition: left 0.3s ease;
    padding: 1rem 0;
}

.sidemenu.active {
    left: 0;
}

.sidemenu-close {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: var(--text-light);
}

.sidemenu-header {
    padding: 0 1rem 1rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.sidemenu-title {
    font-size: 1.25rem;
    font-weight: bold;
    color: var(--primary-color);
}

.sidemenu-list {
    list-style: none;
}

.sidemenu-item {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
}

.sidemenu-item:hover {
    background-color: var(--primary-lightest);
}

.sidemenu-icon {
    margin-right: 0.5rem;
    color: var(--primary-color);
}

/* メインコンテナ */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0.5rem;
}

header {
    /* background-color: white;
    border-radius: 0.5rem;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    margin-bottom: 0.5rem;
    padding: 0.5rem; */
}

h1 {
    /* This is used for the date display in the original index.html logic, but here it's the topbar title. We might need a different element or class for the date title */
    color: var(--primary-dark);
    text-align: center;
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

/* 日付セレクター（中央配置） */
.date-selector {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0.5rem auto;
    width: 100%;
    max-width: 500px;
    /* 幅を広げる */
}

.date-display {
    font-size: 1.25rem;
    font-weight: bold;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    /* background-color: var(--primary-lightest); */
    color: var(--primary-dark);
    text-align: center;
    margin: 0 0.5rem;
    flex-grow: 1;
    white-space: nowrap;
    /* 日付を折り返さない */
}

.date-nav button {
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
}

.date-nav button:hover {
    background-color: var(--primary-dark);
}

/* 表示切替コントロール */
.view-controls {
    display: flex;
    gap: 0.5rem;
    margin: 0.5rem 0 1em 0;
}

/* DAY/WEEK切替 */
.mode-selector {
    display: flex;
    border: 2px solid var(--primary-color);
    border-radius: 2rem;
    overflow: hidden;
    flex-shrink: 0;
}

.mode-option {
    padding: 0.5rem 1.5rem;
    background-color: white;
    color: var(--primary-color);
    cursor: pointer;
    font-weight: bold;
}

.mode-option.active {
    background-color: var(--primary-color);
    color: white;
}

/* ドロップダウン */
.custom-dropdown {
    position: relative;
    flex-grow: 1;
}

.dropdown-toggle {
    width: 100%;
    padding: 0.5rem 1rem;
    /* border: 1px solid var(--primary-color); */
    border-radius: 0.25rem;
    background-color: var(--primary-lightest);
    color: var(--primary-dark);
    font-weight: bold;
    cursor: pointer;
    text-align: center;
    position: relative;
    font-size: 1.25rem;
}

.dropdown-toggle::after {
    content: "";
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid var(--primary-color);
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: white;
    border: 1px solid var(--border-color);
    border-radius: 0.25rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    z-index: 10;
    display: none;
}

.dropdown-menu.show {
    display: block;
}

.dropdown-item {
    padding: 0.5rem 1rem;
    cursor: pointer;
}

.dropdown-item:hover {
    background-color: var(--primary-lightest);
}

.dropdown-item.active {
    background-color: var(--primary-color);
    color: white;
}

/* 時間割コンテナ */
.timetable-container {
    position: relative;
    margin-top: 0.5rem;
}

.update-info {
    font-size: 0.75rem;
    text-align: right;
    color: var(--text-light);
}

.timetable-wrapper {
    background-color: white;
    border-radius: 0.5rem;
    overflow: hidden;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
    overflow-x: auto;
    /* Always allow horizontal scroll */
}

table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    /* Helps with consistent column widths */
}

th,
td {
    border: 1px solid var(--border-color);
    padding: 0.5rem;
    text-align: center;
    vertical-align: middle;
    min-width: 100px;
    /* Minimum width for content cells */
    word-break: break-word;
    white-space: normal;
}

th {
    background-color: var(--primary-lightest);
    color: var(--primary-dark);
    font-weight: 600;
    position: sticky;
    top: 0;
    /* Stick header row */
    z-index: 2;
}

.time-col {
    width: 60px;
    min-width: 60px;
    /* Fixed width for time column */
    background-color: var(--primary-lightest);
    color: var(--primary-dark);
    /* font-weight: 600; */
    position: sticky;
    left: 0;
    /* Stick time column */
    z-index: 1;
}

/* Ensure header time cell is also sticky */
thead th.time-col {
    position: sticky;
    left: 0;
    top: 0;
    font-weight: normal;
    z-index: 3;
    /* Above both sticky row and column */
}

.class-cell {
    padding: 0.1rem;
    height: 100%;
    /* Ensure cell content takes full height */
    display: flex;
    flex-direction: column;
}

.empty-td {
    background-color: #f4f4f4;
    padding: 0;
}

.class-td {
    vertical-align: top;
    margin: 0.1rem;
    padding: 0.2rem;
}

.class-name {
    /* font-weight: bold; */
    font-size: 0.875rem;
    line-height: 1.3;
}

.class-room {
    font-size: 0.75rem;
    color: var(--text-light);
    margin-top: 0.25rem;
    line-height: 1.2;
}

.class-comment {
    /* Added for potential future use */
    font-size: 0.75rem;
    color: var(--text-light);
    font-style: italic;
    margin-top: 0.25rem;
}

.hidden {
    display: none;
}

.overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 150;
    display: none;
}

.overlay.active {
    display: block;
}

/* Header link style */
th a {
    color: var(--primary-dark);
    text-decoration: none;
    font-weight: 600;
}

th a:hover {
    text-decoration: underline;
    color: var(--primary-color);
}

.date-header {
    font-weight: 600;
}

footer a {
    color: var(--primary-dark);
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
    color: var(--primary-color);
}

footer {
    margin-top: 1rem;
    text-align: right;
    color: var(--text-light);
    font-size: 0.9rem;
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
    html {
        font-size: 80%;
    }

    th,
    td {
        min-width: 80px;
        /* Adjust min-width for smaller screens */
    }

    .time-col {
        width: 40px;
        min-width: 40px;
    }

    .empty-td {
        min-height: 40px;
    }

    .mode-option {
        padding: 0.375rem 1rem;
        line-height: 23px;
    }

    .date-display {
        padding: 0.5rem 0.5rem;
    }

    .date-nav button {
        width: 1.5rem;
        height: 1.5rem;
    }

}