/* ログイン画面 */
#login-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
}

.login-card {
    text-align: center;
    padding: 48px 40px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 16px;
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    min-width: 340px;
}

.login-title {
    color: #fff;
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 4px;
}

.login-subtitle {
    color: rgba(255, 255, 255, 0.6);
    font-size: 14px;
    margin-bottom: 36px;
}

.login-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 28px;
    font-size: 15px;
    font-weight: 500;
    border-radius: 8px;
    border: none;
    background: #fff;
    color: #333;
    cursor: pointer;
    transition: box-shadow 0.2s, transform 0.1s;
}

.login-btn:hover {
    box-shadow: 0 4px 16px rgba(66, 133, 244, 0.35);
    transform: translateY(-1px);
}

.login-error {
    color: #ff6b6b;
    font-size: 13px;
    margin-top: 18px;
    min-height: 20px;
}

.btn-restart {
    margin-left: auto;
    padding: 5px 14px;
    font-size: 12px;
    border: 1px solid rgba(231, 76, 60, 0.6);
    border-radius: 4px;
    background: transparent;
    color: rgba(231, 76, 60, 0.85);
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.btn-restart:hover:not(:disabled) {
    background: rgba(231, 76, 60, 0.15);
    color: #e74c3c;
    border-color: #e74c3c;
}

.btn-restart:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-logout {
    padding: 5px 14px;
    font-size: 12px;
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 4px;
    background: transparent;
    color: rgba(255, 255, 255, 0.75);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.btn-logout:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

/* リセット & 基本設定 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: #333;
    background-color: #f5f5f5;
    overflow: hidden;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* ツールバー */
.toolbar {
    background-color: #2c3e50;
    color: #fff;
    padding: 12px 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.toolbar h1 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 10px;
}

.toolbar-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: center;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.control-group label {
    font-size: 13px;
    white-space: nowrap;
}

.control-group input[type="number"] {
    width: 80px;
    padding: 4px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
}

#outputId {
    padding: 4px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.file-name {
    font-size: 12px;
    color: #ecf0f1;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ボタン */
.btn {
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background-color: #3498db;
    color: #fff;
}

.btn-primary:hover:not(:disabled) {
    background-color: #2980b9;
}

.btn-secondary {
    background-color: #95a5a6;
    color: #fff;
}

.btn-secondary:hover:not(:disabled) {
    background-color: #7f8c8d;
}

.btn-control {
    background-color: #27ae60;
    color: #fff;
    padding: 8px 16px;
}

.btn-control:hover:not(:disabled) {
    background-color: #229954;
}

.btn-small {
    font-size: 12px;
}

.btn-danger {
    background-color: #e74c3c;
    color: #fff;
    padding: 8px 16px;
}

.btn-danger:hover:not(:disabled) {
    background-color: #c0392b;
}

/* メインコンテンツ */
.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* 左ペイン: 企業一覧 */
.left-pane {
    width: 320px;
    background-color: #fff;
    border-right: 1px solid #ddd;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.pane-header {
    padding: 15px;
    border-bottom: 1px solid #ddd;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.pane-header h2 {
    font-size: 16px;
    font-weight: 600;
}

.search-box {
    padding: 10px 15px;
    border-bottom: 1px solid #ddd;
}

.search-box input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
}

.company-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

/* 企業アイテム */
.company-item {
    background-color: #ecf0f1;
    border: 2px solid #bdc3c7;
    border-radius: 6px;
    padding: 10px;
    margin-bottom: 8px;
    cursor: grab;
    transition: all 0.2s;
    user-select: none;
}

.company-item:hover {
    background-color: #d5dbdb;
    transform: translateY(-2px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.company-item.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

.company-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}

.company-title {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: flex-start;
    gap: 6px;
}

.company-name {
    font-weight: 600;
    font-size: 14px;
    color: #2c3e50;
    cursor: default;
    min-width: 0;
}

.company-id {
    font-size: 11px;
    color: #7f8c8d;
}

.company-info {
    font-size: 12px;
    color: #7f8c8d;
}

/* 右ペイン: タイムライン */
.right-pane {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: #fff;
    overflow: hidden;
}

.right-pane .pane-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.pane-header-tools {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.playback-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

.timeline-loudness-value {
    font-size: 14px;
    font-weight: 600;
    color: #2c3e50;
    min-width: 100px;
    text-align: center;
}

.timeline-loudness-value.is-pending {
    color: #f39c12;
}

.timeline-loudness-value.is-error {
    color: #e74c3c;
}

/* 波形コンテナ */
.waveform-container {
    background-color: #1a1a1a;
    padding: 20px;
    border-bottom: 1px solid #ddd;
}

#waveform {
    margin-bottom: 10px;
}

#timeline {
    height: 20px;
}

/* タイムラインブロック */
.timeline-blocks {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background-color: #fafafa;
    position: relative;
}

.drop-zone-hint {
    text-align: center;
    color: #95a5a6;
    padding: 40px;
    font-size: 14px;
    border: 2px dashed #bdc3c7;
    border-radius: 8px;
    margin: 20px;
}

.timeline-drop-indicator {
    height: 4px;
    background: #3498db;
    border-radius: 2px;
    margin: 4px 0;
    opacity: 0.9;
}

.timeline-block.drop-target-highlight {
    outline: 2px dashed #3498db;
    outline-offset: 2px;
}

/* タイムラインブロックアイテム */
.timeline-block {
    background-color: #fff;
    border: 2px solid #3498db;
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.2s;
}

.timeline-block:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.timeline-block.selected {
    border-color: #2ecc71;
    background-color: #e8f8f5;
}

.drag-handle {
    cursor: grab;
    font-size: 18px;
    color: #95a5a6;
}

.drag-handle:active {
    cursor: grabbing;
}

.block-title {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: flex-start;
    gap: 6px;
}

.block-name {
    font-weight: 600;
    color: #2c3e50;
    cursor: default;
    min-width: 0;
}

.rename-btn {
    opacity: 1;
    pointer-events: auto;
    border: none;
    background: transparent;
    color: #7f8c8d;
    padding: 2px 6px;
    border-radius: 4px;
    line-height: 0;
}


@media (hover: none) {
    .rename-btn {
        opacity: 1;
        pointer-events: auto;
    }
}

.rename-btn:hover {
    background: #ecf0f1;
    color: #2c3e50;
}

.rename-btn:focus-visible {
    outline: 2px solid #3498db;
    outline-offset: 2px;
    opacity: 1;
    pointer-events: auto;
}

.rename-btn svg {
    display: block;
}

.is-renaming .rename-btn {
    opacity: 0;
    pointer-events: none;
}

.rename-input {
    font: inherit;
    color: #2c3e50;
    padding: 2px 6px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fff;
    flex: 1;
    min-width: 0;
    width: auto;
}

.block-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
}

.block-time-control {
    display: flex;
    align-items: center;
    gap: 5px;
}

.block-time-control label {
    font-size: 12px;
    color: #7f8c8d;
}

.block-time-control input[type="number"] {
    width: 100px;
    padding: 4px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
}

.time-adjust-buttons {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.time-adjust-buttons button {
    padding: 2px 6px;
    font-size: 10px;
    line-height: 1;
}

/* ステータスバー */
.status-bar {
    padding: 10px 20px;
    background-color: #ecf0f1;
    border-top: 1px solid #ddd;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    color: #7f8c8d;
}

/* ドラッグオーバー状態 */
.timeline-blocks.drag-over {
    background-color: #e8f4f8;
    border: 2px dashed #3498db;
}

/* スクロールバー */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #bdc3c7;
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: #95a5a6;
}

/* レスポンシブ調整 */
@media (max-width: 1200px) {
    .left-pane {
        width: 280px;
    }
}

@media (max-width: 768px) {
    .main-content {
        flex-direction: column;
    }

    .left-pane {
        width: 100%;
        max-height: 40vh;
    }
}

/* =========================================
   セグメント編集モーダル（手動分割）
   ========================================= */
.hidden {
    display: none !important;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 1000;
}

.modal {
    width: min(960px, 96vw);
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
    padding: 14px 16px 12px;
    max-height: 90vh;
    overflow: auto;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.modal-title {
    font-size: 16px;
    font-weight: 600;
    color: #2c3e50;
}

.segment-waveform-wrapper {
    position: relative;
    width: 100%;
    background: #111;
    border-radius: 8px;
    padding: 10px;
    overflow-x: auto;
    overflow-y: hidden;
}

.segment-waveform-inner {
    position: relative;
    min-height: 128px;
}

#segmentWaveform {
    /* 幅は Wavesurfer（fillParent: false + minPxPerSec）に任せる。
       マーカーは px 指定のため、下記の width 指定は削除 */
    min-height: 128px;
    width: 100%;
}

.segment-split-marker {
    position: absolute;
    top: 10px;
    bottom: 10px;
    width: 2px;
    background: #ff3b30;
    left: 50%;
    transform: translateX(-1px);
    pointer-events: none;
    border-radius: 2px;
}

.modal-controls {
    display: flex;
    justify-content: space-between;
    margin-top: 16px;
    margin-bottom: 8px;
}

.segment-center-controls {
    display: flex;
    gap: 8px;
}

.btn-slow {
    background-color: #e67e22;
    color: #fff;
    padding: 8px 16px;
}

.btn-slow:hover:not(:disabled) {
    background-color: #d35400;
}

.modal-actions {
    justify-self: end;
    display: flex;
    gap: 8px;
}


@media (max-width: 560px) {
    .modal-controls {
        grid-template-columns: 1fr;
    }
    .segment-center-controls {
        justify-content: space-between;
    }
    .modal-actions {
        justify-self: end;
    }
}

.modal-note {
    font-size: 12px;
    color: #7f8c8d;
    padding-left: 8px;
}
