:root {
    --bg: #f2ede5;
    --surface: #fcfaf7;
    --surface-alt: #f4eee5;
    --surface-muted: #ece4d9;
    --line: #d8ccbe;
    --line-strong: #c6b7a7;
    --text: #221c15;
    --muted: #62574b;
    --accent: #6d4b35;
    --accent-strong: #593725;
    --accent-soft: #e7ddd1;
    --danger: #b55334;
    --success: #4f6232;
    --shadow: 0 2px 8px rgba(34, 28, 21, 0.08);
}

* {
    box-sizing: border-box;
}

html {
    background: var(--bg);
}

body {
    margin: 0;
    color: var(--text);
    background: var(--bg);
    font-family: "Aptos", "Noto Sans", sans-serif;
    line-height: 1.45;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

.app-shell {
    max-width: 1380px;
    margin: 0 auto;
    padding: 24px;
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--line);
}

.app-identity {
    display: inline-block;
    margin-bottom: 10px;
    color: var(--muted);
    font-size: 14px;
}

.app-header h1 {
    margin: 0;
    font-size: clamp(28px, 4vw, 38px);
    font-weight: 600;
    line-height: 1.1;
}

.app-subtitle {
    max-width: 720px;
    margin: 10px 0 0;
    color: var(--muted);
    font-size: 15px;
}

.header-actions,
.inline-actions,
.toolbar-actions,
.segment-tabs,
.shift-controls,
.field-inline,
.status-actions,
.list-actions,
.table-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.app-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    padding: 14px 0 24px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 24px;
}

.app-nav a {
    padding: 0 0 8px;
    color: var(--muted);
    border-bottom: 2px solid transparent;
}

.app-nav a.is-active {
    color: var(--text);
    border-bottom-color: var(--text);
}

.view-switch {
    display: inline-flex;
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
    background: var(--surface);
}

.view-switch a {
    padding: 9px 12px;
    color: var(--muted);
}

.view-switch a.is-active {
    background: var(--surface-alt);
    color: var(--text);
}

.button,
.button-ghost,
.button-danger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 40px;
    padding: 0 14px;
    border-radius: 8px;
    border: 1px solid var(--line-strong);
    background: var(--surface);
    color: var(--text);
}

.button:hover,
.button-ghost:hover,
.button-danger:hover {
    border-color: var(--accent);
}

.button-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fffaf5;
}

.button-primary:hover {
    background: var(--accent-strong);
    border-color: var(--accent-strong);
}

.button-danger {
    color: var(--danger);
}

.button-sm {
    min-height: 34px;
    padding: 0 11px;
    font-size: 13px;
}

.button-xs {
    min-height: 28px;
    padding: 0 9px;
    font-size: 12px;
}

.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: var(--shadow);
    padding: 20px;
}

.panel-tight {
    padding: 14px;
}

.messages {
    list-style: none;
    margin: 0 0 20px;
    padding: 0;
}

.messages li {
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
}

.messages li + li {
    margin-top: 8px;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 0 8px;
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    background: var(--surface-alt);
    color: var(--text);
    font-size: 13px;
}

.status-badge.is-muted {
    color: var(--muted);
}

.status-badge.is-danger {
    border-color: rgba(181, 83, 52, 0.3);
    color: var(--danger);
    background: #fbf3ef;
}

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
}

.toolbar-meta {
    color: var(--muted);
    font-size: 14px;
}

.toolbar-tight {
    margin-bottom: 10px;
}

.table-wrap {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 12px 10px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

.data-table th {
    color: var(--muted);
    font-weight: 600;
}

.data-table tr:last-child td {
    border-bottom: none;
}

.secondary-text {
    color: var(--muted);
}

.muted-block {
    color: var(--muted);
    font-size: 14px;
}

.catalog-layout,
.detail-layout,
.split-layout,
.detail-grid,
.summary-grid,
.segment-summary-grid,
.comment-grid {
    display: grid;
    gap: 20px;
}

.catalog-layout {
    grid-template-columns: 300px minmax(0, 1fr);
    align-items: start;
}

.catalog-layout-tight {
    grid-template-columns: 240px minmax(0, 1fr);
    gap: 14px;
}

.detail-layout {
    grid-template-columns: minmax(0, 1.25fr) minmax(360px, 0.95fr);
    align-items: start;
}

.detail-layout-tight {
    gap: 14px;
}

.detail-grid,
.summary-grid,
.segment-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.detail-grid-compact,
.summary-grid-compact {
    gap: 10px;
}

.field-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.field-grid-tight {
    gap: 10px;
}

.field-pair {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    align-items: start;
}

.field {
    display: grid;
    gap: 6px;
}

.field-wide {
    grid-column: 1 / -1;
}

.field label {
    font-weight: 600;
}

.field-help {
    color: var(--muted);
    font-size: 13px;
}

.field-error {
    color: var(--danger);
    font-size: 13px;
}

input,
select,
textarea {
    width: 100%;
    min-height: 40px;
    padding: 9px 11px;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
}

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

select[multiple] {
    min-height: 120px;
}

input:focus,
select:focus,
textarea:focus,
button:focus {
    outline: 2px solid rgba(109, 75, 53, 0.16);
    outline-offset: 1px;
}

.filter-form {
    display: grid;
    gap: 14px;
}

.compact-filters {
    gap: 8px;
}

.compact-filters select,
.compact-filters input {
    min-height: 34px;
    max-width: 180px;
    padding: 7px 9px;
    font-size: 13px;
}

.results-list,
.stack-list,
.comments-list {
    display: grid;
    gap: 16px;
}

.combo-filters-panel {
    margin-bottom: 14px;
}

.combo-filter-bar {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr)) auto;
    gap: 10px;
    align-items: end;
}

.combo-filter-field {
    min-width: 0;
}

.combo-filter-field select,
.combo-filter-field input {
    min-height: 34px;
    padding: 7px 9px;
    font-size: 13px;
}

.combo-filter-field-narrow select {
    max-width: 110px;
}

.combo-filter-field-year input {
    max-width: 92px;
}

.combo-filter-actions {
    display: grid;
    gap: 6px;
    align-items: start;
    justify-content: flex-end;
    align-content: start;
}

.combo-filter-actions .inline-actions {
    justify-content: flex-end;
}

.combo-grid-minimal {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 14px;
    align-items: start;
}

.combo-card-minimal {
    display: grid;
    gap: 12px;
    align-content: start;
}

.combo-card-media {
    position: relative;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #000;
}

.combo-card-player {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 10;
    background: #000;
}

.combo-card-badges {
    position: absolute;
    inset: 10px 10px auto 10px;
    display: flex;
    justify-content: space-between;
    gap: 8px;
    pointer-events: none;
}

.combo-card-badge-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.combo-card-badges .status-badge {
    background: rgba(252, 250, 247, 0.92);
    backdrop-filter: blur(8px);
}

.combo-card-content {
    display: grid;
    gap: 12px;
}

.combo-card-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
}

.combo-inline-form {
    display: grid;
    gap: 8px;
    margin-top: 8px;
}

.combo-inline-form-compact {
    margin-top: 0;
}

.combo-inline-form-compact select,
.combo-inline-form-compact input {
    min-height: 34px;
    padding: 7px 9px;
    font-size: 13px;
}

.combo-meta-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.combo-meta-chip {
    min-width: 0;
    flex: 1 1 140px;
    display: grid;
    gap: 2px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-alt);
}

.combo-meta-chip strong {
    font-size: 11px;
    line-height: 1.2;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.combo-meta-chip span {
    min-width: 0;
    font-size: 13px;
    line-height: 1.3;
}

.combo-control-strip {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    align-items: start;
}

.combo-empty-control {
    display: flex;
    align-items: center;
    min-height: 34px;
    padding: 7px 9px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-alt);
    font-size: 13px;
}

.combo-dropdown {
    position: relative;
}

.combo-dropdown-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 34px;
    padding: 7px 9px;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    background: #fff;
    font-size: 13px;
    list-style: none;
    cursor: pointer;
}

.combo-dropdown-summary::-webkit-details-marker {
    display: none;
}

.combo-dropdown-summary::after {
    content: "▾";
    color: var(--muted);
    font-size: 11px;
}

.combo-dropdown[open] .combo-dropdown-summary {
    border-color: var(--accent);
}

.combo-dropdown-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: 10;
    width: 100%;
    max-height: 180px;
    overflow-y: auto;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.combo-dropdown-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 4px;
    font-size: 13px;
    cursor: pointer;
}

.combo-dropdown-option + .combo-dropdown-option {
    border-top: 1px solid var(--surface-muted);
}

.combo-dropdown-option input {
    width: auto;
    min-height: 0;
    margin: 0;
}

.stack-list-tight {
    gap: 10px;
}

.combo-row {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    gap: 16px;
    align-items: start;
}

.combo-player,
.video-player {
    display: block;
    width: 100%;
    background: #000;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.combo-player {
    aspect-ratio: 16 / 10;
}

.combo-row-compact {
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 12px;
}

.video-grid-minimal {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 12px;
    align-items: start;
}

.video-card-minimal {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-alt);
    padding: 10px;
    display: grid;
    gap: 8px;
}

.video-preview-wrap {
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
    background: #000;
}

.video-preview {
    width: 100%;
    display: block;
    aspect-ratio: 16 / 10;
}

.video-placeholder {
    min-height: 170px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--muted);
    font-size: 13px;
    padding: 12px;
}

.video-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.video-card-actions {
    display: flex;
    gap: 8px;
}

.detail-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 14px;
}

.detail-card-header h2,
.detail-card-header h3,
.panel h2,
.panel h3 {
    margin: 0;
    font-size: 20px;
}

.detail-card-header-tight {
    margin-bottom: 10px;
}

.detail-card-header-tight h2,
.detail-card-header-tight h3 {
    font-size: 17px;
}

.row-title {
    margin: 0;
    font-size: 19px;
}

.row-subtitle {
    margin-top: 4px;
    color: var(--muted);
    font-size: 14px;
}

.detail-block {
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-alt);
}

.detail-block strong {
    display: block;
    margin-bottom: 6px;
}

.segment-tabs button {
    min-height: 34px;
    padding: 0 12px;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    background: var(--surface);
    color: var(--muted);
}

.segment-tabs button.is-active {
    background: var(--surface-alt);
    color: var(--text);
}

.segment-time {
    font-family: "Consolas", monospace;
    color: var(--muted);
}

.player-wrap {
    margin-bottom: 16px;
}

.time-controls-bar {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-alt);
    padding: 8px 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.time-controls-bar strong {
    font-size: 18px;
    line-height: 1;
}

.current-time {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-alt);
}

.current-time strong {
    font-size: 28px;
    font-weight: 600;
}

.timeline-stack {
    display: grid;
    gap: 14px;
}

.timeline-panel-tight {
    margin-top: 10px;
}

.timeline-lane {
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-alt);
}

.timeline-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.timeline-track {
    position: relative;
    height: 38px;
    border-radius: 999px;
    background: var(--surface-muted);
    overflow: hidden;
}

.timeline-range {
    position: absolute;
    top: 10px;
    height: 18px;
    border-radius: 999px;
}

.timeline-range.dance {
    background: #aa7250;
}

.timeline-range.explanation {
    background: #90725a;
}

.timeline-playhead {
    position: absolute;
    top: 3px;
    bottom: 3px;
    width: 2px;
    background: var(--text);
    opacity: 0.5;
    pointer-events: none;
}

.timeline-marker {
    position: absolute;
    top: 7px;
    width: 24px;
    height: 24px;
    padding: 0;
    border: 2px solid #fff;
    border-radius: 999px;
    transform: translateX(-50%);
}

.timeline-marker.dance {
    background: #7e5237;
}

.timeline-marker.explanation {
    background: #6f5848;
}

.note-box,
.checkbox-box {
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-alt);
}

.checkbox-box {
    display: flex;
    gap: 10px;
    align-items: center;
}

.checkbox-box input {
    width: auto;
    min-height: 0;
    margin: 0;
}

.note-box-danger {
    color: var(--danger);
}

.note-box-compact {
    margin-bottom: 10px;
    padding: 8px 10px;
    font-size: 13px;
}

.checkbox-box-tight {
    padding: 8px 10px;
    font-size: 13px;
}

.compact-form {
    display: grid;
    gap: 10px;
}

.section-gap-tight {
    margin-top: 12px;
}

.comment-item,
.combo-item {
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
}

.comment-item small,
.combo-item small {
    color: var(--muted);
}

.comment-item-tight,
.combo-item-tight {
    padding: 10px;
}

.comment-item-tight p {
    margin: 0;
    white-space: pre-wrap;
}

.segment-summary-grid-tight {
    margin-top: 10px;
    gap: 10px;
}

.compact-helper-grid {
    align-items: stretch;
}

.helper-block {
    padding: 10px 12px;
    display: grid;
    gap: 8px;
    align-content: start;
}

.helper-button-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
}

.helper-button-grid .button-xs,
.helper-preview-row .button-xs {
    width: 100%;
}

.helper-preview-list {
    display: grid;
    gap: 6px;
}

.helper-preview-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
}

.helper-preview-copy {
    min-width: 0;
    font-size: 13px;
    line-height: 1.3;
}

.list-actions-tight {
    margin-top: 8px;
    gap: 6px;
}

.right-editor-panel .field label {
    font-size: 13px;
}

.right-editor-panel .field select,
.right-editor-panel .field input {
    min-height: 34px;
    padding: 7px 9px;
    font-size: 13px;
}

.right-editor-panel textarea {
    min-height: 78px;
}

.comparison-table td:first-child {
    width: 220px;
    font-weight: 600;
}

.empty-state {
    padding: 28px 20px;
    text-align: center;
    color: var(--muted);
}

@media (max-width: 1080px) {
    .combo-filter-bar {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .combo-filter-actions {
        justify-content: flex-start;
    }

    .combo-filter-actions .inline-actions {
        justify-content: flex-start;
    }

    .combo-control-strip,
    .catalog-layout,
    .catalog-layout-tight,
    .detail-layout,
    .detail-layout-tight,
    .combo-row,
    .combo-row-compact,
    .detail-grid,
    .summary-grid,
    .segment-summary-grid,
    .field-grid,
    .field-pair {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 720px) {
    .app-shell {
        padding: 16px;
    }

    .combo-filter-bar,
    .combo-grid-minimal {
        grid-template-columns: 1fr;
    }

    .combo-meta-strip,
    .combo-card-head,
    .app-header,
    .toolbar,
    .time-controls-bar,
    .current-time {
        flex-direction: column;
        align-items: flex-start;
    }

    .helper-button-grid,
    .helper-preview-row {
        grid-template-columns: 1fr;
    }

    .data-table th,
    .data-table td {
        padding-left: 0;
        padding-right: 0;
    }
}
