/* Version 0.1.7 */

@font-face {
    font-family: 'DSEG7Modern';
    src: url('DSEG7Modern-Bold.woff') format('woff');
    font-weight: bold;
    font-style: normal;
}

:root {
    --bg-color: #121316;
    --card-bg: rgba(30, 32, 38, 0.85);
    --popover-bg: #1e2026;
    --dock-bg: rgba(26, 28, 34, 0.88);
    --border-color: rgba(255, 255, 255, 0.12);
    --text-color: #f8fafc;
    --text-muted: #94a3b8;
    --lcd-text: #ffffff;
    --lcd-ghost: rgba(255, 255, 255, 0.06);
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --danger-color: #ef4444;
    --danger-hover: #dc2626;
    --secondary-bg: #2d3139;
    --secondary-hover: #3d424d;

    /* アジェンダ用: 落ち着いたダークモノトーン */
    --agenda-bg: rgba(18, 20, 26, 0.94);
    --agenda-border: rgba(255, 255, 255, 0.1);
    --agenda-card-bg: rgba(255, 255, 255, 0.03);
    --agenda-active-border: #60a5fa;

    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

[data-theme="light"] {
    --bg-color: #f1f5f9;
    --card-bg: rgba(255, 255, 255, 0.9);
    --popover-bg: #ffffff;
    --dock-bg: rgba(255, 255, 255, 0.92);
    --border-color: rgba(0, 0, 0, 0.12);
    --text-color: #0f172a;
    --text-muted: #64748b;
    --lcd-text: #1e293b;
    --lcd-ghost: rgba(0, 0, 0, 0.06);
    --secondary-bg: #e2e8f0;
    --secondary-hover: #cbd5e1;

    --agenda-bg: rgba(241, 245, 249, 0.96);
    --agenda-border: rgba(0, 0, 0, 0.1);
    --agenda-card-bg: rgba(0, 0, 0, 0.03);
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-family);
    height: 100vh;
    width: 100vw;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    overflow: hidden;
    user-select: none;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.version-tag {
    position: absolute;
    top: 16px;
    left: 16px;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: monospace;
    opacity: 0.6;
}

/* メイン表示エリア */
.main-display-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100%;
    padding: 20px 20px 150px 20px;
}

/* アラートステータスバー */
.status-bar {
    width: 100%;
    max-width: 90vw;
    height: 4vh;
    min-height: 24px;
    max-height: 50px;
    margin-bottom: 2vh;
    border-radius: 4px;
    transition: background-color 0.1s ease;
}
.status-bar.status-off { background-color: transparent; }
.status-bar.status-blink { animation: statusBarSignalBlink 0.8s infinite steps(1); }

@keyframes statusBarSignalBlink {
    0%, 49% { opacity: 1; }
    50%, 100% { opacity: 0; }
}

/* デジタル液晶表示 */
.lcd-wrapper {
    position: relative;
    display: inline-block;
    text-align: center;
    line-height: 1;
}
.digital-bg, .timer-digits {
    font-family: 'DSEG7Modern', monospace;
    font-weight: bold;
    letter-spacing: 0.02em;
    line-height: 1;
    white-space: nowrap;
    margin: 0;
    padding: 0;
}
.digital-bg {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    color: var(--lcd-ghost);
    z-index: 1;
}
.timer-digits {
    position: relative;
    color: var(--lcd-text);
    z-index: 2;
}
.lcd-wrapper.format-mmss .digital-bg,
.lcd-wrapper.format-mmss .timer-digits { font-size: min(26vw, 34vh); }
.lcd-wrapper.format-hhmmss .digital-bg,
.lcd-wrapper.format-hhmmss .timer-digits { font-size: min(15vw, 22vh); }

/* 超過カウント表示（メインタイマーとカラー同期） */
.overtime-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    color: var(--text-color);
    margin-top: 3.5vh;
}
.overtime-plus {
    font-family: 'DSEG7Modern', monospace;
    font-size: min(10vw, 14vh);
    font-weight: bold;
    line-height: 1;
    color: var(--lcd-text);
}
.overtime-lcd-wrapper { position: relative; display: inline-block; line-height: 1; }
.overtime-digital-bg, .overtime-digits {
    font-family: 'DSEG7Modern', monospace;
    font-weight: bold;
    letter-spacing: 0.02em;
    line-height: 1;
    white-space: nowrap;
}
.overtime-digital-bg { position: absolute; top: 0; left: 0; right: 0; bottom: 0; color: var(--lcd-ghost); z-index: 1; }
.overtime-digits {
    position: relative;
    color: var(--lcd-text); /* デフォルト色をメインタイマーと統一 */
    z-index: 2;
}
.overtime-lcd-wrapper.format-mmss .overtime-digital-bg,
.overtime-lcd-wrapper.format-mmss .overtime-digits { font-size: min(13vw, 18vh); }
.overtime-lcd-wrapper.format-hhmmss .overtime-digital-bg,
.overtime-lcd-wrapper.format-hhmmss .overtime-digits { font-size: min(8vw, 13vh); }
.overtime-label {
    font-size: min(5vw, 6vh);
    font-weight: 800;
    letter-spacing: 4px;
    margin-left: 8px;
    white-space: nowrap;
    color: var(--text-color);
}

/* 最下部 ドックバー */
.dock-bar {
    position: fixed;
    bottom: 42px;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 24px);
    max-width: 1200px;
    background: var(--dock-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 8px 14px;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    z-index: 40;
    transition: bottom 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.dock-left, .dock-center, .dock-right {
    display: flex;
    align-items: center;
    gap: 8px;
}
.dock-center {
    flex: 1;
    justify-content: center;
    gap: 16px;
}

/* プリセットボタン */
.preset-segmented {
    display: flex;
    background: rgba(0, 0, 0, 0.25);
    padding: 3px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    gap: 3px;
}
.preset-btn {
    background: none;
    border: none;
    color: var(--text-color);
    padding: 6px 10px;
    border-radius: 5px;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: background 0.15s ease;
}
.preset-btn:hover { background: var(--secondary-hover); }

/* 一体型スピンボタンUI */
.time-input-group { display: flex; align-items: center; gap: 8px; }

.time-input-box-unified {
    display: flex;
    align-items: stretch;
    background: #111111;
    border: 1px solid #333333;
    border-radius: 6px;
    overflow: hidden;
    height: 38px;
}

.time-input-box-unified input {
    background: transparent;
    border: none;
    color: var(--lcd-text);
    font-family: 'DSEG7Modern', monospace;
    font-size: 1.6rem;
    width: 48px;
    text-align: center;
    outline: none;
    padding: 0;
    line-height: 1;
}

.time-input-box-unified input::-webkit-outer-spin-button,
.time-input-box-unified input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.time-input-box-unified input[type=number] { -moz-appearance: textfield; }

.spin-column {
    display: flex;
    flex-direction: column;
    width: 22px;
    background: #d4d4d8;
    border-left: 1px solid #333;
}

.spin-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: #111111;
    font-size: 0.65rem;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    transition: background 0.1s ease;
}
.spin-up { border-bottom: 1px solid #a1a1aa; }
.spin-btn:hover { background: #a1a1aa; }

.unit-label { font-size: 0.85rem; font-weight: bold; color: var(--text-muted); white-space: nowrap; }
.control-btn-group { display: flex; gap: 6px; }

.dock-btn {
    border: none;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s ease;
}
.dock-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary { background-color: var(--primary-color); color: #ffffff; }
.btn-primary:hover:not(:disabled) { background-color: var(--primary-hover); }
.btn-primary.is-running { background-color: var(--danger-color); }
.btn-primary.is-running:hover:not(:disabled) { background-color: var(--danger-hover); }
.btn-secondary { background-color: var(--secondary-bg); color: var(--text-color); }
.btn-secondary:hover:not(:disabled) { background-color: var(--secondary-hover); }
.btn-utility { background-color: var(--secondary-bg); color: var(--text-color); border: 1px solid var(--border-color); }
.btn-utility:hover:not(:disabled) { background-color: var(--secondary-hover); }

/* 画面一番下（Dockの下）に常駐するアジェンダエリア */
.agenda-bottom-area {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--agenda-bg);
    border-top: 1px solid var(--agenda-border);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.5);
    z-index: 45;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.agenda-bar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 20px;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s ease;
}
.agenda-bar-header:hover { background: rgba(255, 255, 255, 0.04); }

.agenda-bar-title {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.88rem;
    flex: 1;
    overflow: hidden;
}

.agenda-toggle-icon {
    font-size: 0.7rem;
    transition: transform 0.25s ease;
    display: inline-block;
    color: var(--text-muted);
}

.agenda-bottom-area.collapsed .agenda-toggle-icon {
    transform: rotate(180deg);
}

.agenda-mini-preview {
    font-size: 0.82rem;
    color: #93c5fd;
    font-weight: 600;
    margin-left: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: none;
}

.agenda-bottom-area.collapsed .agenda-mini-preview {
    display: inline-block;
}

.agenda-bottom-area.collapsed .agenda-body-content {
    display: none;
}

.agenda-body-content {
    padding: 10px 20px 14px 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.agenda-bar-actions { display: flex; align-items: center; gap: 8px; }
.btn-csv-label { display: inline-flex; align-items: center; cursor: pointer; gap: 4px; }

.agenda-input-inline-row { display: flex; align-items: center; gap: 8px; }
.agenda-title-field { flex: 2; }
.agenda-assignee-field { flex: 1; min-width: 80px; }
.agenda-min-field { width: 64px; text-align: center; }

.agenda-timeline-container {
    max-height: 180px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-right: 2px;
}

.agenda-timeline-card {
    background: var(--agenda-card-bg);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    padding: 8px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    cursor: grab;
    transition: background 0.15s ease, border-color 0.15s ease;
}
.agenda-timeline-card:hover { background: rgba(255, 255, 255, 0.06); }
.agenda-timeline-card:active { cursor: grabbing; }
.agenda-timeline-card.is-dragging { opacity: 0.4; transform: scale(0.98); }
.agenda-timeline-card.drag-over { border-top: 2px solid var(--primary-color); }

.agenda-timeline-card.is-active {
    border-left: 3px solid var(--agenda-active-border);
    background: rgba(59, 130, 246, 0.08);
}

.agenda-status-tag { font-size: 0.7rem; padding: 2px 6px; border-radius: 4px; font-weight: bold; margin-right: 8px; }
.status-wait { background: rgba(255, 255, 255, 0.1); color: var(--text-muted); }
.status-run { background: #2563eb; color: #ffffff; }

.drag-handle {
    cursor: grab;
    margin-right: 8px;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.btn-muted-action {
    background: #334155;
    color: #f8fafc;
    border: none;
}
.btn-muted-action:hover:not(:disabled) { background: #475569; }

.btn-sub-danger {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.4);
}
.btn-sub-danger:hover:not(:disabled) { background: rgba(239, 68, 68, 0.35); }

.free-limit-badge { font-size: 0.75rem; background: rgba(239, 68, 68, 0.15); color: #fca5a5; border: 1px solid var(--danger-color); padding: 2px 6px; border-radius: 4px; }

.custom-input, .custom-select {
    background: var(--bg-color);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 0.85rem;
    outline: none;
}
.custom-select { background: var(--secondary-bg); padding: 5px 8px; }

.btn-action-small { background: var(--secondary-bg); color: var(--text-color); border: 1px solid var(--border-color); padding: 4px 8px; border-radius: 4px; font-size: 0.75rem; cursor: pointer; white-space: nowrap; transition: opacity 0.2s; }
.btn-action-small:hover:not(:disabled) { background: var(--secondary-hover); }
.btn-action-small:disabled { opacity: 0.3; cursor: not-allowed; }

.btn-primary-inline { background: var(--primary-color); color: white; border: none; }
.btn-danger-small { background: var(--danger-color); color: white; border: none; padding: 4px 8px; border-radius: 4px; font-size: 0.75rem; cursor: pointer; white-space: nowrap; transition: opacity 0.2s; }
.btn-danger-small:disabled { opacity: 0.3; cursor: not-allowed; }
.btn-full-width { background: var(--secondary-bg); color: var(--text-color); border: 1px dashed var(--border-color); padding: 10px; border-radius: 6px; font-size: 0.85rem; font-weight: 600; cursor: pointer; }

/* アジェンダ編集モーダル */
.modal-card-agenda-edit { width: 420px; text-align: left; }
.modal-card-agenda-edit h3 { font-size: 1rem; font-weight: bold; margin-bottom: 16px; border-bottom: 1px solid var(--border-color); padding-bottom: 8px; }
.agenda-edit-form { display: flex; flex-direction: column; gap: 12px; margin-bottom: 20px; }
.agenda-edit-form .form-row { display: flex; flex-direction: column; gap: 4px; }
.full-field { width: 100%; }
.min-field { width: 80px; text-align: center; }
.modal-footer-btn-row { display: flex; justify-content: flex-end; gap: 8px; }

/* 独立プリセット設定ダイアログモーダル */
.preset-dialog-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 380px;
    background: #232429;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 10px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
    z-index: 100;
    overflow: hidden;
}

.preset-dialog-header { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid rgba(255, 255, 255, 0.1); }
.preset-dialog-header h3 { font-size: 1rem; font-weight: 700; color: #ffffff; }
.preset-dialog-body { padding: 20px 22px; display: flex; flex-direction: column; gap: 20px; }
.preset-time-row { display: flex; justify-content: center; align-items: center; gap: 8px; }

.preset-input-box { background: #111215; border: 1px solid #383a42; border-radius: 6px; padding: 4px; }
.preset-input-box input { background: transparent; border: none; color: #ffffff; font-family: 'DSEG7Modern', monospace; font-size: 1.8rem; font-weight: bold; width: 60px; text-align: center; outline: none; }
.preset-input-box input::-webkit-outer-spin-button, .preset-input-box input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.preset-input-box input[type=number] { -moz-appearance: textfield; }

.preset-action-group { display: flex; flex-direction: column; gap: 10px; }
.preset-action-btn { width: 100%; padding: 12px; border-radius: 6px; font-size: 0.9rem; font-weight: 700; cursor: pointer; text-align: center; transition: all 0.15s ease; border: none; }
.btn-secondary-block { background: #3c3f47; color: #f1f5f9; }
.btn-secondary-block:hover { background: #4b4f59; }
.btn-primary-block { background: #1d61f2; color: #ffffff; }
.btn-primary-block:hover { background: #154ec5; }
.btn-cancel-block { background: #2d3038; color: #cbd5e1; border: 1px solid rgba(255, 255, 255, 0.1); }
.btn-cancel-block:hover { background: #393d47; }

/* ポップオーバーパネル */
.popover-panel {
    position: fixed;
    bottom: 96px;
    right: 20px;
    width: 380px;
    background: var(--popover-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
    z-index: 50;
    overflow: hidden;
}
.popover-panel.popover-wide { width: 480px; }
.popover-header { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border-color); }
.popover-header h3 { font-size: 0.95rem; font-weight: 700; }
.popover-close-btn { background: none; border: none; color: var(--text-muted); font-size: 1.3rem; cursor: pointer; line-height: 1; }
.popover-body { padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; }

/* 各種設定カード */
.alert-item-card, .system-section-card { background: rgba(0, 0, 0, 0.25); border: 1px solid var(--border-color); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.alert-card-start { border-left: 4px solid var(--primary-color); background: rgba(37, 99, 235, 0.08); }
.alert-card-header { display: flex; justify-content: space-between; align-items: center; font-size: 0.85rem; padding-bottom: 4px; border-bottom: 1px solid var(--border-color); }
.alert-section-box { background: rgba(0, 0, 0, 0.2); border: 1px solid rgba(255, 255, 255, 0.06); border-radius: 6px; padding: 8px 10px; display: flex; flex-direction: column; gap: 6px; }
.alert-section-title, .system-section-title { font-size: 0.75rem; font-weight: bold; color: var(--text-muted); }
.system-section-title { font-size: 0.85rem; color: var(--text-color); }
.alert-inline-group { display: flex; align-items: center; gap: 10px; }

.radio-group-column { display: flex; flex-direction: column; gap: 10px; }
.radio-label.block-radio-label { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; cursor: pointer; white-space: normal; width: 100%; }

.license-inner-box { display: flex; flex-direction: column; gap: 10px; }
.license-status-row { display: flex; justify-content: space-between; align-items: center; font-size: 0.85rem; }
.license-input-inline-group { display: flex; gap: 8px; }
.key-field { flex: 1; }
.license-deactivate-row { display: flex; justify-content: flex-end; }
.license-badge { font-size: 0.75rem; padding: 3px 8px; border-radius: 4px; font-weight: bold; }
.license-badge.free { background: var(--secondary-bg); color: var(--text-muted); }
.license-badge.pro { background: var(--primary-color); color: white; }

.color-chips-group { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.color-chip { width: 22px; height: 22px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.2); transition: transform 0.15s ease, border-color 0.15s ease; padding: 0; }
.color-chip:hover { transform: scale(1.15); }
.color-chip.is-selected { border-color: #ffffff; box-shadow: 0 0 0 2px var(--primary-color); transform: scale(1.1); }
.color-chip-default { background: #ffffff; }
.color-chip-add { background: var(--secondary-bg); border: 1px dashed var(--border-color); color: var(--text-color); font-size: 0.8rem; font-weight: bold; display: flex; justify-content: center; align-items: center; }

.audio-setting-row { display: flex; align-items: center; gap: 8px; }
.audio-filename { font-size: 0.8rem; color: var(--lcd-text); max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: rgba(255, 255, 255, 0.05); padding: 2px 6px; border-radius: 4px; }
.alerts-scroll-area { max-height: 260px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding-right: 4px; }

.lock-icon-inline { font-size: 0.75rem; opacity: 0.9; }

/* モーダル (z-index 1000) */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}
.modal-card { background: var(--popover-bg); border: 1px solid var(--border-color); border-radius: 12px; padding: 24px; width: 400px; text-align: center; }
.modal-icon { font-size: 2.5rem; margin-bottom: 12px; }
.modal-title { font-size: 1.2rem; font-weight: bold; margin-bottom: 8px; }
.modal-message { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 20px; line-height: 1.5; }
.modal-input-group { display: flex; gap: 8px; margin-bottom: 12px; }
.key-input { flex: 1; background: var(--bg-color); color: var(--text-color); border: 1px solid var(--border-color); padding: 8px 12px; border-radius: 6px; font-size: 0.9rem; }
.error-msg { color: #fca5a5; font-size: 0.8rem; margin-top: 4px; }
.modal-footer { margin-top: 16px; }
.text-btn { background: none; border: none; color: var(--text-muted); font-size: 0.85rem; cursor: pointer; text-decoration: underline; }
.text-btn:hover { color: var(--text-color); }

/* レスポンシブ */
@media (max-width: 1024px) {
    .dock-bar { flex-wrap: wrap; justify-content: center; }
    .dock-center { order: -1; width: 100%; justify-content: center; margin-bottom: 4px; }
}
@media (max-width: 768px) {
    .popover-panel.popover-wide { width: calc(100vw - 32px); right: 16px; }
}

.hidden { display: none !important; }