/* --- 変数定義 (カラーパレット・フォント) --- */
:root {
    --bg-color: #121212;
    --text-color: #e0e0e0;
    --panel-bg: rgba(255, 255, 255, 0.05);
    --panel-border: rgba(255, 255, 255, 0.1);
    --primary-color: #bb86fc;
    --secondary-color: #03dac6;
    --accent-color: #cf6679;
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* --- 基本設定 (リセット・背景) --- */
body {
    margin: 0;
    padding: 0;
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
    background-image: radial-gradient(circle at top right, #1f1f1f 0%, #121212 100%);
    overflow-x: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

/* Hide scrollbar globally */
*::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
}

html {
    scrollbar-width: none;
    -ms-overflow-style: none;
}

/* --- 全体レイアウト (グリッド構成) --- */
.app-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    min-height: 100vh;
    gap: 1.5rem;
    padding: 1.5rem;
    box-sizing: border-box;
    align-items: start;
}

/* --- 共通パネルデザイン (グラスモーフィズム) --- */
.glass-panel {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

.title-header a {
    color: inherit;
    text-decoration: none;
}

.memo-container {
    margin-top: 1.5rem;
}

.memo-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.memo-label {
    color: var(--text-color);
    font-size: 1rem;
    margin-bottom: 0.5rem;
    opacity: 0.9;
}

.sound-controls {
    font-size: 0.8rem;
    opacity: 0.8;
    display: flex;
    align-items: center;
    gap: 8px;
}

#chimeSelect {
    background: rgba(0, 0, 0, 0.3);
    color: var(--text-color);
    border: 1px solid var(--panel-border);
    border-radius: 4px;
    padding: 1px 4px;
    font-size: 0.85rem;
    cursor: pointer;
    outline: none;
}

.title-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

h1 {
    font-size: 1.5rem;
    color: var(--primary-color);
    margin: 0;
    font-weight: bold;
    font-family: 'Quicksand', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    min-height: 1.8rem;
    display: block;
}

h2 {
    font-size: 1.1rem;
    color: var(--secondary-color);
    margin-top: 0;
    margin-bottom: 1rem;
    font-weight: normal;
}

p {
    font-size: 0.8rem;
    color: #aaa;
    margin: 0.5rem 0 0 0;
}

.divider {
    height: 1px;
    background: var(--panel-border);
    margin: 1.5rem 0;
}

/* --- サイドバー (左側/スマホ上部) --- */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.sidebar-upper {
    flex: 0 0 auto;
}

.memo-area {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--panel-border);
    color: var(--text-color);
    padding: 0.8rem;
    border-radius: 8px;
    font-family: var(--font-family);
    width: 100%;
    box-sizing: border-box;
    font-size: 1.0rem;
    resize: vertical;
    min-height: 40px;
}

.checkbox-row {
    display: flex;
    justify-content: flex-start;
    flex-wrap: wrap;
    column-gap: 1rem;
    row-gap: 0.5rem;
    margin-top: 1.0rem;
    font-size: 1.0rem;
    color: #ccc;
    align-items: center;
}

.wakeup-item {
    width: 100%;
    flex: 0 0 100%;
    margin-bottom: 0;
    color: var(--text-color);
    opacity: 0.9;
    margin-right: 0.5rem;
    font-weight: normal;
}

#baseWakeupTime {
    width: auto;
    padding: 2px 8px;
    font-size: 1.0rem;
    border: 1px solid #ffffff;
    border-radius: 15px;
    background: rgba(0, 0, 0, 0.3);
    color: var(--secondary-color);
    font-family: inherit;
    cursor: pointer;
    outline: none;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.checkbox-item:hover {
    opacity: 1;
}

.checkbox-item input[type="checkbox"],
#chimeEnabled,
#chimeSelect {
    accent-color: var(--secondary-color);
    cursor: pointer;
}

#chimeSelect:focus {
    border-color: var(--secondary-color);
}

.sidebar-lower {
    display: flex;
    flex-direction: column;
}

.status-highlight {
    font-size: 1.3rem;
    font-weight: normal;
    color: var(--primary-color);
    text-align: center;
    padding: 1rem;
    background: rgba(187, 134, 252, 0.1);
    border-radius: 8px;
    margin-top: 0.5rem;
}

.list-section {
    display: flex;
    flex-direction: column;
    margin-top: 1.5rem;
}

.list-scroll-container {
    border-top: 1px solid var(--panel-border);
    padding-top: 0.5rem;
}

#shiftedScheduleList {
    list-style: none;
    padding: 0;
    font-size: 0.9rem;
    color: #ccc;
    margin: 0;
}

#shiftedScheduleList li {
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

/* --- メインコンテンツ (右側/スマホ下部) --- */
.main-content {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.chart-area {
    min-height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0rem;
    position: relative;
}

/* --- Theme Selector --- */
.theme-select {
    position: absolute;
    top: 10px;
    right: 15px;
    z-index: 100;
    background: rgba(0, 0, 0, 0.4);
    color: var(--secondary-color);
    border: 1px solid var(--panel-border);
    border-radius: 6px;
    padding: 2px 8px;
    font-size: 0.8rem;
    cursor: pointer;
    outline: none;
    backdrop-filter: blur(5px);
    transition: all 0.2s ease;
}

.theme-select:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
}

.theme-select option {
    background: #1e1e1e;
    color: #fff;
}

.input-area {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

.individual-settings,
.bulk-import {
    display: flex;
    flex-direction: column;
}

/* --- シフト操作UI (スライダー・ボタン) --- */
.shift-control-panel {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.shift-label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--secondary-color);
    font-size: 1.1rem;
    font-weight: normal;
}

.shift-controls-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.btn-icon {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    font-size: 2rem;
    line-height: 1;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    color: var(--primary-color);
    border: 1px solid var(--panel-border);
    cursor: pointer;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.2);
}

#shiftHours {
    text-align: center;
    font-size: 1.2rem;
    font-weight: bold;
    appearance: textfield;
    width: 100px;
    flex: 0 0 auto;
}

.shift-range {
    width: 100%;
    margin-top: 0.5rem;
    accent-color: var(--primary-color);
    cursor: pointer;
    background: rgba(255, 255, 255, 0.1);
    height: 12px;
    border-radius: 6px;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.shift-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    margin-top: 0px;
}

/* --- 入力フォーム & ボタン共通設定 --- */
.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

input[type="time"]::-webkit-calendar-picker-indicator {
    display: none;
    -webkit-appearance: none;
}

input[type="text"],
input[type="time"],
input[type="number"],
textarea {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--panel-border);
    color: var(--text-color);
    padding: 0.8rem;
    border-radius: 8px;
    font-family: var(--font-family);
    width: 100%;
    box-sizing: border-box;
    font-size: 1.0rem;
}

textarea {
    resize: vertical;
    min-height: 100px;
}

#bulkInput {
    font-size: 1.0rem;
}

.time-inputs {
    display: flex;
    gap: 0.5rem;
}

.time-inputs label {
    flex: 1;
    display: flex;
    flex-direction: column;
    font-size: 0.8rem;
}

button {
    padding: 0.8rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

button:active {
    transform: scale(0.98);
}

.btn-primary {
    background-color: var(--primary-color);
    color: #000;
}

.btn-secondary {
    background-color: transparent;
    border: 1px solid var(--panel-border);
    color: var(--text-color);
}

#testChimeBtn {
    padding: 2px 8px;
    font-size: 0.8rem;
    border-radius: 4px;
}

#importBtn {
    margin-top: 0.5rem;
}

.import-note {
    font-size: 0.8rem;
    color: #aaa;
    margin-top: 0.5rem;
}

/* --- Schedule List Delete Button --- */
.delete-shifted-btn {
    background: none;
    border: none;
    color: var(--accent-color);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0 0.5rem;
    opacity: 0.6;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.delete-shifted-btn:hover {
    opacity: 1;
    transform: scale(1.2);
}

/* --- クラウド同期UI (Refactored) --- */
.sync-section {
    padding: 1.2rem;
}

.sync-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.sync-status {
    font-size: 1rem;
    margin-right: 5px;
    transition: color 0.3s ease;
}

.sync-status.active {
    color: var(--secondary-color);
    text-shadow: 0 0 8px var(--secondary-color);
}

.sync-status.inactive {
    color: #555;
}

.sync-header h2 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--secondary-color);
    font-weight: 400;
}

.sync-token-area {
    display: flex;
    align-items: center;
    gap: 8px;
}

.gh-token-wrapper {
    width: 220px;
    opacity: 0.3;
    transition: opacity 0.3s;
}

.gh-token-wrapper:hover, .gh-token-wrapper:focus-within {
    opacity: 1;
}

input.gh-token-input {
    width: 100%;
    padding: 6px 10px;
    font-size: 0.8rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--panel-border);
    border-radius: 6px;
    color: white;
    outline: none;
    box-sizing: border-box;
}

.btn-share {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    filter: brightness(0.8);
    padding: 0;
    transition: transform 0.2s;
}

.btn-share:hover {
    transform: scale(1.1);
    filter: brightness(1);
}

.sync-id-row {
    position: relative;
    width: 100%;
    margin-bottom: 12px;
}

input.sync-id-input {
    width: 100%;
    padding: 12px 10px 12px 35px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    font-size: 1.0rem;
    color: white;
    box-sizing: border-box;
    font-family: inherit;
}

.sync-note {
    font-size: 0.7rem;
    color: #888;
    margin-top: 5px;
    margin-left: 12px;
    opacity: 0.8;
}

.sync-status-dot {
    position: absolute;
    left: 12px;
    top: 22px;
    transform: translateY(-50%);
    font-size: 10px;
    color: #555;
}

.sync-control-stack {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 10px;
}

.sync-btn-row {
    display: flex;
    gap: 10px;
    width: 100%;
    align-items: stretch;
}

.sync-block-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    padding: 12px 14px;
    cursor: pointer;
    transition: background 0.2s;
}

.sync-block-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

.sync-block-label {
    font-size: 0.9rem;
    font-weight: normal;
    color: white;
}

.sync-block-time {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.5);
}

.btn-new-id {
    flex: 0 0 auto;
    padding: 0 15px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.5);
    border-radius: 8px;
    cursor: pointer;
    white-space: nowrap;
    font-size: 0.9rem;
    font-weight: normal;
    transition: all 0.2s;
}

.btn-new-id:hover {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.8);
}

/* --- Shift Control UI Refactor --- */
.shift-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.8rem;
}

.reset-link {
    color: var(--secondary-color);
    text-decoration: none;
    font-size: 1.1rem;
    opacity: 0.8;
    cursor: pointer;
    transition: opacity 0.2s;
    font-weight: normal;
}

.reset-link:hover {
    opacity: 1;
}

.usage-guide-link,
.usage-guide-link:visited {
    color: var(--secondary-color);
    text-decoration: none;
    font-size: 0.85rem;
    border-bottom: 1px dotted var(--secondary-color);
    opacity: 0.8;
    transition: opacity 0.2s;
}

.usage-guide-link:hover {
    opacity: 1;
}

.shift-ui-container {
    display: flex;
    gap: 15px;
    align-items: stretch;
    height: 80px;
}

.shift-btn-group {
    display: flex;
    gap: 10px;
}

.btn-shift-tall {
    width: 68px;
    height: 100%;
    border-radius: 12px;
    font-size: 1.8rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    color: var(--primary-color);
    border: 1px solid var(--panel-border);
    cursor: pointer;
    transition: background 0.2s;
    padding: 0;
}

.btn-shift-tall:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
}

.shift-value-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.shift-display-box {
    flex: 1;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.shift-display-input {
    background: none;
    border: none;
    text-align: center;
    font-size: 1.5rem;
    font-weight: bold;
    color: #fff;
    width: 100%;
    outline: none;
    padding: 0;
}

.shift-section .shift-range {
    margin-top: 0;
    width: 100%;
}

/* --- Share Modal UI --- */
#shareModal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.share-panel {
    padding: 2rem;
    text-align: center;
    max-width: 90%;
    position: relative;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

#closeShareModal {
    position: absolute;
    top: 10px;
    right: 15px;
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
}

.share-title {
    margin-top: 0;
    color: var(--secondary-color);
}

#qrcode {
    background: white;
    padding: 15px;
    border-radius: 8px;
    margin: 1rem auto;
    width: fit-content;
}

.share-note {
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.share-btn-row {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
}

#copyLinkBtn {
    font-size: 0.9rem;
}

#copyMsg {
    height: 1.2em;
    color: var(--secondary-color);
    font-size: 0.8rem;
    margin-top: 0.5rem;
}

/* --- レスポンシブ対応 (スマホ向けレイアウト) --- */
@media (max-width: 900px) {
    .app-layout {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        padding: 1rem;
        gap: 1.5rem;
    }

    .sidebar {
        height: auto;
        position: relative;
        top: 0;
        border-bottom: 1px solid var(--panel-border);
        padding-bottom: 1.5rem;
        width: 100%;
        box-sizing: border-box;
    }

    .main-content {
        width: 100%;
        box-sizing: border-box;
    }

    .list-section {
        max-height: 400px;
    }

    .input-area {
        grid-template-columns: 1fr;
    }

    .glass-panel {
        width: 100%;
        box-sizing: border-box;
    }
}
