:root {
    --bg: #f5f7fb;
    --panel: #ffffff;
    --panel-soft: #eef3f8;
    --ink: #18212f;
    --muted: #627084;
    --line: #dde5ef;
    --blue: #2563eb;
    --green: #12805c;
    --amber: #b45309;
    --red: #c2410c;
    --purple: #7c3aed;
    --shadow: 0 16px 40px rgba(24, 33, 47, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    background: var(--bg);
    font-family: Arial, Helvetica, sans-serif;
    letter-spacing: 0;
}

body.device-mobile [data-mobile-hidden] {
    display: none !important;
}

body.device-mobile .live-comments-panel,
body.device-mobile .live-log-stream {
    width: 100%;
}

body.device-mobile .content-grid.two-columns {
    grid-template-columns: 1fr;
}

body.device-mobile .live-comments-panel {
    grid-column: 1 / -1;
    min-height: min(680px, calc(100vh - 180px));
}

body.device-mobile .live-comment-list {
    max-height: 58vh;
}

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

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

.app-shell {
    display: grid;
    grid-template-columns: 264px minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 18px 14px;
    overflow-y: auto;
    background: #101827;
    color: #ecf3ff;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 8px;
    color: white;
    background: #2563eb;
    font-weight: 800;
}

.brand strong,
.brand span {
    display: block;
}

.brand span {
    color: #9fb2cf;
    font-size: 12px;
    margin-top: 2px;
}

.nav-list {
    display: grid;
    gap: 4px;
    margin-top: 22px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 38px;
    padding: 9px 10px;
    border-radius: 8px;
    color: #c9d7ea;
    font-size: 14px;
}

.nav-item:hover,
.nav-item.is-active {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.1);
}

.nav-icon {
    width: 16px;
    height: 16px;
    border: 1.5px solid currentColor;
    border-radius: 5px;
    flex: 0 0 auto;
    opacity: 0.9;
}

.main {
    min-width: 0;
    padding: 22px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 64px;
    margin-bottom: 18px;
}

.topbar h1 {
    margin: 2px 0 0;
    font-size: 26px;
    line-height: 1.15;
}

.topbar-title {
    min-width: 0;
    flex: 1 1 auto;
}

.topbar-title h1 {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.eyebrow {
    margin: 0;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.topbar-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    min-width: 0;
}

.shop-context-form {
    min-width: 260px;
}

.shop-context-form label {
    display: grid;
    gap: 4px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}

.shop-context-form select {
    min-height: 34px;
    padding: 7px 9px;
    font-size: 13px;
    text-transform: none;
}

.shop-context-empty {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 7px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--blue);
    background: var(--panel);
    font-size: 13px;
    font-weight: 700;
}

.db-pill,
.status-badge {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 6px 10px;
    border-radius: 999px;
    color: var(--muted);
    background: #e8edf5;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.db-pill.is-online,
.status-badge.is-running {
    color: #0f6b4e;
    background: #dcf8ed;
}

.db-pill.is-demo {
    color: #92520c;
    background: #fff1d6;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 260px;
    padding: 6px 8px 6px 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--panel);
    font-size: 13px;
}

.user-chip span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-chip a {
    color: var(--blue);
    font-weight: 700;
}

.account-menu {
    position: relative;
}

.account-menu summary {
    list-style: none;
}

.account-menu summary::-webkit-details-marker {
    display: none;
}

.account-trigger {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--panel);
    cursor: pointer;
    box-shadow: 0 10px 22px rgba(24, 33, 47, 0.08);
}

.account-avatar {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: 999px;
    color: #ffffff;
    background: var(--blue);
    font-size: 14px;
    font-weight: 800;
}

.account-avatar.large {
    width: 44px;
    height: 44px;
    font-size: 18px;
}

.account-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    z-index: 40;
    display: grid;
    gap: 12px;
    width: min(340px, calc(100vw - 32px));
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: 0 18px 48px rgba(24, 33, 47, 0.16);
}

.account-profile {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr);
    gap: 10px;
    align-items: center;
}

.account-profile strong,
.account-profile span,
.account-meta dd {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.account-profile span {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.account-meta {
    display: grid;
    gap: 8px;
    margin: 0;
    padding: 10px 0;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}

.account-meta div {
    display: grid;
    grid-template-columns: 78px minmax(0, 1fr);
    gap: 8px;
}

.account-meta dt {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.account-meta dd {
    margin: 0;
    color: var(--ink);
    font-size: 13px;
    font-weight: 700;
}

.account-shop-form label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.account-shop-form select {
    min-height: 38px;
    text-transform: none;
}

.account-shop-empty,
.account-link,
.account-logout {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-weight: 800;
}

.account-shop-empty {
    color: var(--blue);
    background: #f4f7fc;
}

.account-link {
    color: var(--blue);
    background: #f4f7fc;
}

.account-logout {
    color: #ffffff;
    border-color: var(--red);
    background: var(--red);
}

.notice {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 16px;
    padding: 12px 14px;
    border: 1px solid #f6d58a;
    border-radius: 8px;
    color: #72420d;
    background: #fff8e8;
}

.dashboard-grid,
.content-grid {
    display: grid;
    gap: 16px;
    margin-bottom: 16px;
}

.dashboard-grid {
    grid-template-columns: minmax(0, 1.7fr) minmax(280px, 0.8fr);
}

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

.operation-panel,
.health-panel,
.panel,
.module-header {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.operation-panel,
.health-panel,
.panel {
    padding: 18px;
}

.module-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 16px;
    padding: 18px;
}

.module-header h2,
.section-heading h2,
.panel h2 {
    margin: 3px 0 0;
    font-size: 20px;
    line-height: 1.2;
}

.module-header p {
    max-width: 760px;
    margin: 8px 0 0;
    color: var(--muted);
}

.auto-live-warning {
    max-width: none;
    margin-top: 10px;
    margin-bottom: 10px;
    padding: 10px 12px;
    border: 1px solid #f3c35b;
    border-radius: 8px;
    color: #7a4b00;
    background: #fff4d6;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.5;
}

.comment-worker-simple-form {
    gap: 12px;
}

.worker-mode-toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    width: fit-content;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f7f9fc;
    color: var(--text);
    font-weight: 700;
}

.worker-mode-toggle input {
    width: 18px;
    height: 18px;
    accent-color: var(--blue);
}

.worker-simple-status {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
    color: var(--muted);
    font-size: 13px;
}

.worker-simple-status strong {
    color: var(--text);
}

.section-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.live-readout {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.live-readout div {
    min-height: 76px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f9fbfe;
}

.live-readout span,
.stat-card span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 7px;
}

.live-readout strong {
    display: block;
    overflow-wrap: anywhere;
    line-height: 1.25;
}

.quick-actions,
.module-actions,
.control-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.quick-actions {
    margin-top: 16px;
}

.button,
.icon-button,
.icon-text-button {
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--ink);
    background: #ffffff;
    cursor: pointer;
    font-weight: 700;
}

.button {
    min-height: 38px;
    padding: 9px 14px;
}

.button.small {
    min-height: 32px;
    padding: 6px 10px;
    font-size: 13px;
}

.button.primary {
    color: white;
    border-color: var(--blue);
    background: var(--blue);
}

.button.is-loading,
.button[aria-busy="true"] {
    opacity: 0.58;
    cursor: wait;
    pointer-events: none;
}

.button.danger {
    color: white;
    border-color: var(--red);
    background: var(--red);
}

.button:hover,
.icon-text-button:hover {
    filter: brightness(0.96);
}

.icon-text-button {
    min-height: 30px;
    padding: 5px 9px;
    color: var(--blue);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.stat-card {
    min-height: 104px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.stat-card strong {
    font-size: 30px;
}

.tone-blue { border-top: 4px solid var(--blue); }
.tone-green { border-top: 4px solid var(--green); }
.tone-purple { border-top: 4px solid var(--purple); }
.tone-amber { border-top: 4px solid var(--amber); }

.dashboard-observer {
    display: grid;
    gap: 16px;
    margin-bottom: 16px;
}

.dashboard-live-panel {
    min-height: auto;
}

.dashboard-stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.dashboard-comments-panel,
.dashboard-log-panel {
    margin-bottom: 16px;
}

.dashboard-comment-list {
    min-height: 320px;
    max-height: 48vh;
}

.dashboard-log-stream {
    max-height: 320px;
}

.dashboard-comment-card .live-comment-meta {
    padding-right: 0;
}

.dashboard-comment-card .comment-reply-status {
    margin-top: 2px;
}

.health-list {
    display: grid;
    gap: 12px;
}

.health-list div {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 42px;
    padding: 10px;
    border-radius: 8px;
    background: #f9fbfe;
}

.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--muted);
}

.dot.ok { background: var(--green); }
.dot.warn { background: var(--amber); }

.timeline {
    display: grid;
    gap: 12px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.timeline li {
    display: grid;
    grid-template-columns: 62px minmax(0, 1fr);
    gap: 12px;
    align-items: center;
    padding: 10px;
    border-left: 4px solid var(--line);
    border-radius: 8px;
    background: #f9fbfe;
}

.timeline li.done { border-left-color: var(--green); }
.timeline li.running { border-left-color: var(--blue); }
.timeline li.waiting { border-left-color: var(--amber); }

.timeline time {
    color: var(--muted);
    font-weight: 700;
}

.comment-list {
    display: grid;
    gap: 10px;
}

.comment-list article {
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f9fbfe;
}

.comment-list p {
    margin: 5px 0;
}

.comment-list span {
    color: var(--muted);
    font-size: 12px;
}

.comment-center-table {
    min-width: 980px;
}

.comment-center-table tbody tr.has-reply {
    background: #fbfffd;
}

.comment-center-content {
    max-width: 520px;
    margin: 0;
    color: var(--ink);
    line-height: 1.45;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.comment-center-reply {
    max-width: 520px;
    color: var(--ink);
    line-height: 1.45;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.comment-center-reply.is-empty {
    color: var(--muted);
    font-style: italic;
}

.comment-center-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.comment-center-pagination,
.pagination-actions,
.comment-reply-edit-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
}

.comment-center-pagination {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
}

.pagination-actions {
    justify-content: flex-end;
}

.comment-reply-edit-form {
    display: grid;
    gap: 8px;
    margin-top: 10px;
}

.comment-reply-edit-form textarea {
    width: 100%;
    min-height: 110px;
    resize: vertical;
}

.comment-reply-edit-actions {
    justify-content: flex-start;
}

.comment-detail-row td {
    padding: 0 10px 14px;
    background: #f9fbfe;
}

.comment-detail-panel {
    display: grid;
    gap: 14px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
}

.comment-detail-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}

.comment-detail-grid div,
.comment-detail-copy div,
.comment-debug-grid details {
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f9fbfe;
}

.comment-detail-grid span,
.comment-detail-copy span {
    display: block;
    margin-bottom: 5px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
}

.comment-detail-grid strong,
.comment-detail-copy p {
    margin: 0;
    color: var(--ink);
    font-size: 13px;
    line-height: 1.45;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.ai-reply-inline-action,
.ai-reply-composer {
    display: grid;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafc;
}

.ai-reply-inline-action {
    grid-template-columns: auto 1fr;
    align-items: center;
}

.ai-reply-composer[hidden],
.ai-reply-inline-action[hidden] {
    display: none;
}

.ai-reply-composer-header,
.ai-reply-composer-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
}

.ai-reply-composer-header span {
    display: block;
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
}

.ai-reply-composer-header strong {
    color: var(--ink);
    font-size: 13px;
}

.ai-reply-composer textarea {
    width: 100%;
    min-height: 88px;
    resize: vertical;
}

.comment-detail-copy,
.comment-debug-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.comment-detail-copy div:first-child {
    grid-column: 1 / -1;
}

.comment-debug-grid summary {
    cursor: pointer;
    color: var(--blue);
    font-weight: 800;
}

.comment-debug-grid pre {
    max-height: 220px;
    margin: 10px 0 0;
    overflow: auto;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.ai-knowledge-filter-form,
.ai-knowledge-form {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.ai-knowledge-form label,
.ai-knowledge-filter-form label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.ai-knowledge-form textarea {
    min-height: 96px;
    font-family: inherit;
}

.ai-knowledge-form label {
    grid-column: span 2;
}

.ai-knowledge-form label.full-span,
.ai-knowledge-form .full-span {
    grid-column: 1 / -1;
}

.ai-knowledge-form .checkbox-label {
    align-content: center;
    grid-template-columns: auto 1fr;
    gap: 8px;
    color: var(--ink);
}

.ai-knowledge-form .checkbox-label input {
    width: auto;
    margin-top: 2px;
}

.ai-knowledge-form .quick-actions {
    grid-column: 1 / -1;
}

.ai-knowledge-analyze-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.ai-knowledge-analyze-row .form-hint {
    margin: 0;
}

.ai-knowledge-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 16px;
}

.ai-knowledge-tabs a {
    min-height: 34px;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--ink);
    background: #ffffff;
    font-size: 13px;
    font-weight: 800;
}

.ai-knowledge-tabs a:hover,
.ai-knowledge-tabs a.is-active {
    color: #ffffff;
    border-color: var(--blue);
    background: var(--blue);
}

.ai-knowledge-section {
    margin-bottom: 16px;
}

.ai-knowledge-editor {
    margin-bottom: 14px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f9fbfe;
}

.ai-knowledge-editor summary,
.ai-knowledge-row-actions summary {
    cursor: pointer;
    color: var(--blue);
    font-weight: 800;
}

.ai-knowledge-row-actions {
    margin-bottom: 8px;
}

.ai-knowledge-table {
    min-width: 1040px;
}

.ai-knowledge-table td {
    max-width: 320px;
    overflow-wrap: anywhere;
}

.size-audio-panel {
    margin: 8px 0;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
}

.size-audio-panel summary {
    cursor: pointer;
    color: var(--blue);
    font-weight: 800;
}

.size-audio-row-panel {
    min-width: 280px;
}

.size-audio-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 10px;
}

.size-audio-card {
    display: grid;
    gap: 8px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fbff;
}

.size-audio-card audio {
    width: 100%;
    min-width: 180px;
}

.size-audio-upload-form {
    display: grid;
    gap: 8px;
}

.size-audio-upload-form input[type="file"] {
    width: 100%;
    min-width: 0;
}

.ai-reply-rule-table {
    min-width: 1180px;
}

.ai-reply-rule-table td:nth-child(3) {
    max-width: 420px;
}

.ai-rule-bulk-actions {
    align-items: center;
    margin: 10px 0;
}

.rule-auto-checkbox {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 32px;
    color: var(--ink);
    font-size: 13px;
    font-weight: 800;
    white-space: nowrap;
}

.rule-auto-checkbox input {
    width: auto;
    margin: 0;
}

.inline-delete-form {
    display: inline-block;
}

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

.alert {
    padding: 13px 14px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: var(--panel);
}

.alert.warning {
    border-color: #f6d58a;
    color: #72420d;
    background: #fff8e8;
}

.warning-text {
    color: #72420d;
    font-weight: 700;
}

.alert.info {
    border-color: #b9d1ff;
    color: #174ea6;
    background: #edf4ff;
}

.alert.danger {
    border-color: #ffc9b8;
    color: #9b2f12;
    background: #fff1ec;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 720px;
}

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

th {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
}

tbody tr:hover {
    background: #f9fbfe;
}

.search-box,
.automation-form label,
.live-start-form label,
.live-share-form label,
.comment-reply-form label,
.obs-form label,
.obs-source-form label,
.stream-key-box label,
.view-shop-form label,
.video-form label,
.user-form label,
.settings-form label,
.sync-form label,
.login-form label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

input,
select {
    width: 100%;
    min-height: 38px;
    padding: 9px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--ink);
    background: white;
}

textarea {
    width: 100%;
    min-height: 260px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--ink);
    background: white;
    font-family: Consolas, "Courier New", monospace;
    font-size: 13px;
    line-height: 1.5;
    resize: vertical;
}

button:disabled,
.button[disabled] {
    cursor: not-allowed;
    opacity: 0.55;
}

.flash {
    margin-bottom: 16px;
    padding: 12px 14px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: var(--panel);
    font-weight: 700;
}

.flash.success {
    color: #0f6b4e;
    border-color: #b8efd9;
    background: #e8fbf3;
}

.flash.error {
    color: #9b2f12;
    border-color: #ffc9b8;
    background: #fff1ec;
}

.local-json-form {
    display: grid;
    gap: 12px;
}

.settings-form {
    display: grid;
    gap: 12px;
}

.user-form {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.user-form .shop-assignment,
.user-form .quick-actions {
    grid-column: 1 / -1;
}

.inline-edit {
    display: inline-block;
    max-width: min(520px, 80vw);
    margin: 0 8px 8px 0;
    vertical-align: top;
}

.inline-edit summary {
    cursor: pointer;
    list-style: none;
}

.inline-edit summary::-webkit-details-marker {
    display: none;
}

.compact-form {
    grid-template-columns: repeat(2, minmax(180px, 1fr));
    min-width: min(520px, 78vw);
    margin-top: 10px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.compact-form .shop-checkbox-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-height: 220px;
    overflow: auto;
}

.shop-assignment {
    display: grid;
    gap: 10px;
}

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

.checkbox-row {
    display: flex !important;
    align-items: center;
    gap: 8px !important;
    min-height: 42px;
    padding: 9px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-soft);
}

.checkbox-row input {
    width: auto;
}

.connection-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: -4px 0 16px;
}

.connection-tabs a {
    min-height: 38px;
    padding: 9px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--muted);
    background: #ffffff;
    font-weight: 700;
}

.connection-tabs a.is-active {
    color: #ffffff;
    border-color: var(--blue);
    background: var(--blue);
}

.oauth-config-list {
    margin-top: 4px;
}

.product-toolbar {
    display: grid;
    grid-template-columns: minmax(260px, 0.9fr) minmax(320px, 1.1fr);
    gap: 14px;
    align-items: start;
}

.view-shop-form {
    display: grid;
    gap: 12px;
}

.video-form {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.video-form .quick-actions {
    grid-column: 1 / -1;
}

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

.product-toolbar .sync-form {
    grid-template-columns: minmax(180px, 1fr) auto;
    align-items: end;
}

.inline-filter {
    min-width: 220px;
}

.inline-action-form {
    display: inline-flex;
    margin: 0;
}

.inline-filter label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.sync-form .quick-actions {
    grid-column: 1 / -1;
}

.product-toolbar .sync-form .quick-actions {
    grid-column: auto;
    margin-top: 0;
    align-self: end;
}

.form-hint {
    margin: 12px 0 0;
    color: var(--muted);
}

.product-table {
    min-width: 980px;
}

.user-table {
    min-width: 1040px;
}

.video-table {
    min-width: 1100px;
}

.video-product-cell {
    display: grid;
    grid-template-columns: 58px minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    min-width: 260px;
}

.product-thumb {
    display: block;
    width: 58px;
    height: 58px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f3f6fb;
    object-fit: cover;
}

.product-thumb.placeholder {
    display: grid;
    place-items: center;
    color: var(--muted);
    font-size: 11px;
    text-align: center;
}

.code-pill {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 5px 8px;
    border-radius: 8px;
    color: #174ea6;
    background: #edf4ff;
    font-size: 12px;
    overflow-wrap: anywhere;
}

.subtle {
    display: block;
    margin-top: 5px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.35;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 16px;
}

.pagination span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.button.is-disabled {
    pointer-events: none;
    opacity: 0.5;
}

.obs-form,
.obs-source-form,
.stream-key-box {
    display: grid;
    gap: 12px;
}

.obs-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.obs-form label:nth-child(3),
.obs-form .quick-actions {
    grid-column: 1 / -1;
}

.obs-source-form {
    grid-template-columns: 1fr;
}

.obs-log {
    display: grid;
    gap: 6px;
    max-height: 150px;
    margin-top: 14px;
    overflow: auto;
    color: var(--muted);
    font-size: 13px;
}

.obs-requirement {
    margin-top: 14px;
}

.obs-file-state {
    min-height: 30px;
    padding: 7px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--muted);
    background: #f4f7fc;
    font-size: 12px;
    font-weight: 700;
}

.obs-file-state.is-ready {
    color: #0f6b4e;
    background: #dcf8ed;
}

.obs-summary {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 6px 10px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--muted);
    background: #f4f7fc;
    font-size: 12px;
    font-weight: 800;
}

.obs-video-table {
    min-width: 980px;
}

.automation-health {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.automation-status-card {
    display: grid;
    gap: 8px;
    min-height: 150px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.automation-status-card span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.automation-status-card strong {
    overflow-wrap: anywhere;
    font-size: 20px;
    line-height: 1.2;
}

.shop-live-status-row {
    margin: 2px 0 4px;
}

.shop-live-status-row .status-badge {
    width: fit-content;
    text-transform: none;
}

.automation-status-card p {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.45;
}

.session-live-link {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
    min-width: 0;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f9fbfe;
}

.session-live-link[hidden] {
    display: none;
}

.session-live-link span {
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
}

.session-live-link a {
    overflow: hidden;
    color: var(--blue);
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.automation-form,
.live-start-form,
.live-cover-upload-form,
.live-share-form {
    display: grid;
    gap: 12px;
}

.live-share-form {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    margin-bottom: 14px;
}

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

.cover-field {
    align-items: start;
}

.live-cover-preview {
    width: 180px;
    max-width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f4f7fc;
}

.cover-url-value {
    display: block;
    max-width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f9fbfe;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.45;
    white-space: normal;
    overflow-wrap: anywhere;
}

.live-cover-upload-form {
    padding-bottom: 14px;
    margin-bottom: 14px;
    border-bottom: 1px solid var(--line);
}

.live-cart-dialog {
    width: min(920px, calc(100vw - 32px));
    max-height: min(760px, calc(100vh - 48px));
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: 0 18px 60px rgb(15 23 42 / 25%);
    overflow: auto;
}

.live-cart-dialog::backdrop {
    background: rgb(15 23 42 / 35%);
}

.compact-heading {
    align-items: center;
    margin-bottom: 10px;
}

.compact-heading h3 {
    margin: 0;
    font-size: 15px;
    line-height: 1.25;
}

.live-comments-panel {
    align-self: start;
    display: flex;
    flex-direction: column;
    min-height: 640px;
}

.live-comment-mode-switch {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    flex-wrap: wrap;
}

.live-comment-mode-switch .button.is-active {
    color: #ffffff;
    border-color: var(--blue);
    background: var(--blue);
}

.live-comment-mode-switch .button {
    min-height: 32px;
    padding-inline: 10px;
    white-space: nowrap;
}

.ai-size-voice-settings {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
}

.ai-size-voice-settings .automation-form {
    gap: 10px;
}

.live-comment-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 360px;
    max-height: 64vh;
    overflow: auto;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f7f9fc;
    scroll-behavior: smooth;
}

.comment-sync-state {
    margin: -4px 0 12px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--muted);
    background: #f4f7fc;
    font-size: 12px;
    line-height: 1.4;
}

.live-comment-card {
    display: grid;
    gap: 8px;
    align-self: flex-start;
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 6px 18px rgba(24, 33, 47, 0.05);
}

.live-comment-card.has-suggestion {
    border-color: #b9d2ff;
    background: #fbfdff;
}

.live-comment-card.is-target {
    border-color: var(--blue);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.14);
}

.live-comment-card.is-replied {
    background: #fbfdff;
}

.live-comment-card p,
.live-comment-text {
    margin: 0;
    color: var(--ink);
    line-height: 1.45;
}

.live-comment-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    color: var(--muted);
    font-size: 12px;
}

.live-comment-meta strong {
    color: var(--ink);
    font-size: 13px;
}

.live-comment-meta span {
    padding: 3px 7px;
    border-radius: 999px;
    background: #e8edf5;
    font-weight: 800;
}

.live-comment-reply-pick {
    margin-left: auto;
}

.comment-reply-status {
    display: grid;
    gap: 4px;
    padding: 9px 10px;
    border: 1px solid #b8efd9;
    border-radius: 8px;
    background: #e8fbf3;
}

.comment-reply-status.is-suggested {
    border-color: #cbd7ea;
    background: #eef4ff;
}

.comment-reply-status span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.live-comment-inline-reply {
    display: grid;
    gap: 8px;
    padding: 10px;
    border: 1px solid #b9d2ff;
    border-radius: 8px;
    background: #eef5ff;
}

.live-comment-inline-reply > span,
.live-comment-inline-reply > p {
    display: none;
}

.live-comment-suggestion-head {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: baseline;
    justify-content: space-between;
}

.live-comment-suggestion-head span {
    color: var(--blue);
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.live-comment-suggestion-head small {
    color: var(--muted);
    font-size: 12px;
}

.live-comment-inline-reply textarea {
    width: 100%;
    min-height: 58px;
    resize: vertical;
    border: 1px solid #cbd7ea;
    border-radius: 8px;
    padding: 9px 10px;
    background: #ffffff;
    color: var(--ink);
    font-family: inherit;
    font-size: 14px;
    line-height: 1.45;
}

.live-comment-inline-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.live-comment-inline-actions .subtle {
    font-size: 12px;
}

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

.comment-reply-form.is-submitting {
    opacity: 0.72;
}

.comment-composer-form {
    z-index: 2;
    margin-top: 10px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 -10px 28px rgba(24, 33, 47, 0.08);
}

.comment-composer-target {
    min-height: 20px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

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

.comment-composer-row textarea {
    width: 100%;
    min-height: 42px;
    max-height: 126px;
    resize: none;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.45;
}

.comment-composer-row .button {
    min-width: 74px;
    min-height: 42px;
}

.compact-settings-list {
    margin: 0 0 12px;
}

.stop-live-form {
    margin-top: 12px;
}

.product-mini-list {
    display: grid;
    gap: 10px;
}

.product-mini-list article {
    display: grid;
    grid-template-columns: 54px minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    min-height: 64px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f9fbfe;
}

.product-mini-list strong,
.product-mini-list span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.product-mini-list .mapping-badge {
    display: inline-block;
    width: fit-content;
    margin-top: 4px;
    padding: 3px 7px;
    border-radius: 999px;
    color: #0f6b4e;
    background: #e7f7ee;
    font-size: 11px;
    font-weight: 800;
}

.cart-picker-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-bottom: 14px;
}

.cart-picker-toolbar .obs-summary {
    margin-right: auto;
}

.live-product-picker {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 10px;
    max-height: 360px;
    margin-bottom: 18px;
    overflow: auto;
    padding: 4px;
}

.live-product-choice {
    display: grid;
    grid-template-columns: 22px 54px minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    min-height: 72px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    cursor: pointer;
}

.live-product-choice[hidden],
.live-product-choice[data-live-cart-hidden-existing="1"] {
    display: none !important;
}

.live-product-choice:has(input:checked) {
    border-color: var(--blue);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.14);
}

.live-product-choice input {
    width: 18px;
    height: 18px;
}

.live-product-choice span {
    display: grid;
    gap: 4px;
    min-width: 0;
}

.live-product-choice strong,
.live-product-choice small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.live-product-choice small {
    color: var(--muted);
    font-size: 12px;
}

.live-product-choice em {
    width: fit-content;
    padding: 3px 7px;
    border-radius: 999px;
    color: #0f6b4e;
    background: #e7f7ee;
    font-size: 11px;
    font-style: normal;
    font-weight: 800;
}

.live-product-choice em.is-in-cart {
    color: #175cd3;
    background: #e8f0ff;
}

.live-log-stream {
    display: grid;
    gap: 10px;
    max-height: 360px;
    overflow: auto;
    padding-right: 4px;
}

.live-log-entry {
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-left: 4px solid var(--blue);
    border-radius: 8px;
    background: #f9fbfe;
}

.live-log-entry.warning {
    border-left-color: var(--amber);
}

.live-log-entry.danger,
.live-log-entry.error {
    border-left-color: var(--red);
}

.live-log-entry p {
    margin: 6px 0 0;
    line-height: 1.45;
}

.live-log-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    color: var(--muted);
    font-size: 12px;
}

.live-log-meta strong {
    color: var(--ink);
    text-transform: uppercase;
}

#automationObsStatus.is-connected {
    color: #0f6b4e;
}

#automationObsStatus.is-disconnected {
    color: #9b2f12;
}

.obs-scene-field {
    display: grid;
    gap: 6px;
    margin: 10px 0;
    font-size: 13px;
    color: var(--muted);
}

.obs-scene-field select {
    width: 100%;
    min-height: 36px;
}

.live-monitor-panel {
    margin-bottom: 16px;
}

.live-link-box {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f9fbfe;
}

.live-link-box span {
    display: block;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.live-link-box strong {
    display: block;
    overflow-wrap: anywhere;
    line-height: 1.35;
}

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

.control-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.stream-key-box {
    margin-top: 16px;
}

.settings-list {
    display: grid;
    gap: 10px;
    margin: 0;
}

.settings-list div {
    display: grid;
    grid-template-columns: 150px minmax(0, 1fr);
    gap: 12px;
    padding: 10px;
    border-radius: 8px;
    background: #f9fbfe;
}

.settings-list dt {
    color: var(--muted);
    font-weight: 700;
}

.settings-list dd {
    margin: 0;
    overflow-wrap: anywhere;
}

.checklist {
    display: grid;
    gap: 10px;
    margin: 0;
    padding-left: 20px;
}

.login-body {
    display: grid;
    place-items: center;
    padding: 20px;
    background: #eef3f8;
}

.login-panel {
    width: min(440px, 100%);
    padding: 24px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.login-brand {
    margin-bottom: 20px;
}

.login-panel h1 {
    margin: 0 0 8px;
    font-size: 26px;
}

.login-panel p {
    margin: 0 0 18px;
    color: var(--muted);
}

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

.form-error {
    margin-bottom: 14px;
    padding: 10px 12px;
    border: 1px solid #ffc9b8;
    border-radius: 8px;
    color: #9b2f12;
    background: #fff1ec;
}

.mobile-only {
    display: none;
}

.icon-button {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
}

.hamburger,
.hamburger::before,
.hamburger::after {
    display: block;
    width: 18px;
    height: 2px;
    background: var(--ink);
    content: "";
}

.hamburger::before {
    transform: translateY(-6px);
}

.hamburger::after {
    transform: translateY(4px);
}

@media (max-width: 1100px) {
    .dashboard-grid,
    .two-columns,
    .alert-row,
    .automation-health {
        grid-template-columns: 1fr;
    }

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

@media (max-width: 820px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: fixed;
        z-index: 20;
        transform: translateX(-100%);
        transition: transform 160ms ease;
        width: 264px;
    }

    .sidebar.is-open {
        transform: translateX(0);
    }

    .main {
        padding: 16px;
    }

    .mobile-only {
        display: grid;
    }

    .topbar {
        align-items: center;
    }

    .module-header {
        align-items: stretch;
        flex-direction: column;
    }

    .topbar-actions {
        flex: 0 0 auto;
    }

    .shop-context-form {
        min-width: 0;
    }

    .live-readout,
    .comment-detail-grid,
    .comment-detail-copy,
    .comment-debug-grid,
    .ai-knowledge-filter-form,
    .ai-knowledge-form,
    .stats-grid,
    .range-grid,
    .live-share-form,
    .live-link-box,
    .obs-form,
    .obs-source-form,
    .control-grid,
    .product-toolbar,
    .product-toolbar .sync-form,
    .user-form,
    .shop-checkbox-grid,
    .video-form,
    .sync-form {
        grid-template-columns: 1fr;
    }

    .product-toolbar .sync-form .quick-actions {
        grid-column: 1 / -1;
    }

    .settings-list div {
        grid-template-columns: 1fr;
    }

    .ai-knowledge-form label {
        grid-column: 1 / -1;
    }
}
