/* Global Styles */
html {
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;  /* Firefox */
}

html::-webkit-scrollbar {
    display: none;  /* Chrome, Safari, Opera */
}

.app-container {
    max-width: 1000px;
}

/* Layout & Navigation */
nav.bottom {
    padding: 0;
}
nav.bottom .tabs {
    width: 100%;
    height: 100%;
}
nav.bottom .tabs a {
    text-align: center;
    min-width: 0;
    padding: 0;
    height: 100%;
} 
nav.bottom .tabs a.active {
    color: var(--primary);
}
nav.bottom .tabs a .small-text {
    font-size: 0.75rem;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}
.tab-page {
    display: none;
}
.tab-page.active {
    display: block;
}
.tabs>a.active:before {
    inset: 0 0 auto 0;
}
.checkbox {
/* Common Components */
    z-index: 2; /* .wave:after の z-index:1 より高くしてクリックイベントを優先 */
}
.task-card {
    box-shadow: none;
    border: .0625rem solid var(--primary);
}
.task-card .task-body {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.4s ease-in-out, opacity 0.4s ease-in-out;
}
.task-card.is-open .task-body {
    /*
     * コンテンツの高さに追従して開くアニメーションを実現するため、
     * max-height には想定されるコンテンツの高さを十分に超える値を設定します。
     */
    display: block !important;
    max-height: 2000px;
    opacity: 1;
    visibility: visible;
}
.selection-panel {
    padding: 10px 12px;
    margin-bottom: 10px;
}
.selection-panel .row {
    flex-wrap: nowrap;
    align-items: center;
    gap: 12px;
    overflow-x: auto;
}
.selection-panel .selection-field {
    flex: 1 1 180px;
    min-width: 140px;
}
#selection-cource {
    flex: 2 1 220px;
}
.selection-panel .field {
    width: 100%;
}
.selection-panel .field select {
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.selection-panel .field select option {
    white-space: nowrap;
}

/* Preparation Page: Task Group Tabs */
.task-group-tabs {
    margin: 16px 0;
}
.task-group-tabs .tabs {
    justify-content: flex-start; /* 左寄せにする */
    overflow-x: auto;
    white-space: nowrap;
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;  /* Firefox */
}
.task-group-tabs .tabs::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}
.task-group-tabs .tabs a {
    flex-shrink: 0; /* タブが縮まないようにする */
    inline-size: auto; /* コンテンツ幅に合わせて表示 */
    flex: 1; /* タブを均等に分割 */
    text-align: center; /* テキストを中央揃え */
}

/* Preparation Page: Phase Summary Card */
.phase-summary-card {
    border-radius: 18px;
    overflow: hidden;
    box-shadow: none;
}
.phase-summary-card .row {
    gap: 12px;
}
.phase-summary-top {
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    min-width: 0;
}
.phase-summary-top > div:first-child {
    min-width: 0;
    flex: 1 1 auto;
}
.phase-summary-name {
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    line-height: 1.2;
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.phase-summary-percentage {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: 0.02em;
    min-width: 4rem;
    text-align: right;
    flex-shrink: 0;
}
.phase-progress {
    margin-top: 12px;
}
.phase-progress-label {
    display: flex;
    justify-content: flex-start;
    font-size: 0.82rem;
    color: var(--on-surface-variant);
    margin-top: 8px;
}
.phase-progress-bar {
    width: 100%;
    height: 10px;
    border-radius: 999px;
    background-color: var(--surface-variant);
    background-color: var(--outline-variant);
    overflow: hidden;
}
.phase-progress-fill {
    height: 100%;
    background-color: var(--primary);
    transition: width 0.3s ease;
}

.task-card.is-completed {
/* Preparation Page: Task Card */
    opacity: 0.6;
}
.task-card.is-completed .task-title {
    text-decoration: line-through;
}
.task-card .expand-icon {
    transition: transform 0.3s ease;
}
.task-card.is-open .expand-icon {
    transform: rotate(180deg);
}

/* Preparation Page: Task Contents */
.step-item {
    position: relative; padding-left: 16px; margin-bottom: 12px;
    font-size: 0.875rem; line-height: 1.5; color: var(--on-surface-variant);
}
.step-item::before {
    content: ''; position: absolute; left: 0; top: 8px;
    width: 4px; height: 4px; border-radius: 50%; background-color: var(--on-surface-variant);
}
.manual-img {
    width: 100%;
    max-width: 500px;
    height: auto;
    object-fit: contain;
    border-radius: 8px; margin: 8px 0 16px 0; border: 1px solid var(--outline-variant);
    display: block; background-color: var(--surface-variant);
}

/* Help Page: Chat UI */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    gap: 12px;
    padding: 12px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 12px 0 120px 0;
}
.chat-message {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
    animation: slideUp 0.3s ease-out;
}
.chat-message.user {
    justify-content: flex-end;
}

.chat-message.assistant {
    justify-content: flex-start;
}
.chat-bubble {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 16px;
    word-wrap: break-word;
    line-height: 1.4;
    white-space: pre-wrap;
    font-size: 0.95rem;
}
.chat-message.user .chat-bubble {
    background-color: var(--primary);
    color: var(--on-primary);
    border-bottom-right-radius: 4px;
}
.chat-message.assistant .chat-bubble {
    background-color: var(--surface-container-highest);
    color: var(--on-surface);
    border: 1px solid var(--outline-variant);
    border-bottom-left-radius: 4px;
}
.chat-bubble.loading-bubble {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.loading-bubble .dot {
    width: 8px;
    height: 8px;
    background-color: currentColor;
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}
.loading-bubble .dot:nth-child(1) {
    animation-delay: -0.32s;
}
.loading-bubble .dot:nth-child(2) {
    animation-delay: -0.16s;
}
@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1.0); }
}

.chat-input-area {
    position: fixed;
    bottom: 80px;
    left: 0;
    right: 0;
    padding: 12px;
    border-top: 1px solid var(--outline-variant);
    background-color: var(--surface);
    display: flex;
    gap: 8px;
    align-items: flex-end;
    z-index: 10;
}
.chat-input-area .row {
    align-items: flex-end;
    width: 100%;
    gap: 8px;
}
.chat-input-area input {
    flex: 1;
    min-height: 40px;
    min-width: 0;
}
.chat-input-area .button {
    flex-shrink: 0;
    min-height: 40px;
    min-width: 40px;
    padding: 8px;
}

/* Schedule Page: Layout & FAB */
.schedule-container {
    position: relative;
    height: 100%;
}
.fab {
    position: fixed;
    bottom: 100px;
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 100;
    padding: 0;
}

.fab:hover {
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}
.fab .svg-icon {
    width: 24px;
    height: 24px;
}

.dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.dialog-content {
    background-color: var(--surface);
    border-radius: 28px;
    padding: 24px;
    max-width: 90%;
    width: 400px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    animation: slideUp 0.3s ease-out;
}

/* Dialog: Form Elements */
.form-group {
    margin-bottom: 16px;
}
.form-group label {
    display: block;
    font-size: 0.875rem;
    color: var(--on-surface-variant);
    margin-bottom: 8px;
    font-weight: 500;
}
.dialog-content .form-group .checkbox {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
}
#isEventCheckbox {
    width: auto;
}
.dialog-content #end-time-group {
    transition: opacity 0.2s ease;
}
.dialog-content .row > .form-group.max {
    flex: 1;
    min-width: 0;
}
.color-selector {
    display: flex;
    gap: 12px;
    margin-top: 8px;
}
.color-selector label {
    display: block;
    cursor: pointer;
}
.color-selector input[type="radio"] {
    display: none;
}
.color-selector .color-swatch {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid var(--outline-variant);
    transition: transform 0.2s ease, border-color 0.2s ease;
}
.color-selector input[type="radio"]:checked + .color-swatch {
    transform: scale(1.15);
    border-width: 3px;
}
.color-swatch.primary { background-color: var(--primary); border-color: var(--primary); }
.color-swatch.secondary { background-color: var(--secondary); border-color: var(--secondary); }
.color-swatch.tertiary { background-color: var(--tertiary); border-color: var(--tertiary); }
.color-swatch.error { background-color: var(--error); border-color: var(--error); }
.color-swatch.grape { background-color: #6750A4; border-color: #6750A4; }
.color-swatch.sage { background-color: #006D5B; border-color: #006D5B; }
.color-swatch.sky { background-color: #00639B; border-color: #00639B; }
.color-swatch.banana { background-color: #795500; border-color: #795500; }
.color-swatch.tomato { background-color: #B3261E; border-color: #B3261E; }
.color-swatch.graphite { background-color: #5F6368; border-color: #5F6368; }

/* Schedule Page: Current Time Line */
.current-time-line {
    position: absolute;
    left: 0;
    right: 0;
    height: 2px;
    background-color: var(--error);
    z-index: 50;
    pointer-events: none;
    display: none; /* JSで表示を制御 */
    transition: top 1s linear;
}
.current-time-line::before {
    content: '';
    position: absolute;
    left: -5px;
    top: 50%;
    transform: translateY(-50%);
    width: 10px;
    height: 10px;
    background-color: var(--error);
    border-radius: 50%;
    border: 2px solid var(--surface);
}
.current-time-label {
    position: absolute;
    right: 8px;
    top: -20px;
    font-size: 0.8rem;
    color: var(--error);
    font-weight: bold;
    /* background-color: var(--surface); */
    padding: 1px 5px;
    border-radius: 4px;
}

/* Schedule Page: Calendar Layout */
.schedule-container {
    height: calc(100vh - 140px);
    position: relative;
    overflow: hidden;
}

.schedule-calendar {
    display: flex;
    height: 100%;
    background-color: var(--surface-variant);
    overflow-y: auto;
}

.time-column {
    width: 60px;
    border-right: 1px solid var(--outline-variant);
    position: sticky;
    left: 0;
    z-index: 1;
}

.timeline-column {
    flex: 1;
    position: relative;
    background-color: var(--surface);
}

.timeline-grid {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}
.timeline-grid::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: linear-gradient(to bottom, var(--outline-variant) 1px, transparent 1px);
    background-size: 100% 60px;
}

/* Schedule Page: Schedule Items */
.schedule-items {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}
.schedule-item {
    position: absolute;
    left: 4px;
    right: 4px;
    background-color: var(--primary-container);
    color: var(--on-primary-container);
    border-left: 3px solid var(--primary);
    border-radius: 8px;
    padding: 4px 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    pointer-events: auto;
    overflow: hidden;
    z-index: 10;
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
}
.schedule-item.schedule-event {
    height: 22px;
    align-items: center;
    padding: 2px 8px;
}
.schedule-item.schedule-event .svg-icon {
    display: none;
}

/* Schedule Page: Item Color Variations */

.schedule-item.grape {
    background-color: #EADDFF;
    color: #21005D;
    border-left-color: #6750A4;
}

.schedule-item.sage {
    background-color: #D8E8E3;
    color: #00201B;
    border-left-color: #006D5B;
}

.schedule-item.sky {
    background-color: #D0E6FF;
    color: #001D33;
    border-left-color: #00639B;
}

.schedule-item.banana {
    background-color: #FFDE9C;
    color: #261800;
    border-left-color: #795500;
}

.schedule-item.tomato {
    background-color: #FFDAD6;
    color: #410002;
    border-left-color: #B3261E;
}

.schedule-item.graphite {
    background-color: #E2E2E6;
    color: #1C1B1F;
    border-left-color: #5F6368;
}

/* Schedule Page: Item & Time Label Text */
.schedule-item .schedule-title {
    font-weight: 500;
    font-size: 0.8rem;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}
.time-label {
    position: absolute;
    right: 8px;
    transform: translateY(-50%);
    font-size: 0.75rem;
    color: var(--on-surface-variant);
    font-weight: 500;
}
.schedule-item.schedule-event .schedule-title {
    font-size: 0.75rem;
    line-height: 1;
}

/* Animations */
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
@keyframes bounce {
    0%, 80%, 100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1.0);
    }
}