:root {
    color-scheme: light;
    --bg: #f4f7fb;
    --surface: #ffffff;
    --text: #17202e;
    --muted: #667085;
    --line: #d9e1ec;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --accent: #059669;
    --danger: #dc2626;
    --warning: #b45309;
    --shadow: 0 20px 45px rgba(22, 34, 51, 0.08);
}

* {
    box-sizing: border-box;
}

html {
    overflow-x: hidden;
}

body {
    margin: 0;
    min-height: 100vh;
    overflow-x: hidden;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button {
    max-width: 100%;
    min-height: 38px;
    border: 0;
    border-radius: 8px;
    padding: 0 13px;
    background: var(--primary);
    color: white;
    cursor: pointer;
    font-weight: 700;
    transition: background 140ms ease, border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

button:hover {
    background: var(--primary-dark);
}

button:active {
    transform: translateY(1px);
}

button.secondary {
    border: 1px solid #dbe4ef;
    background: #f3f7fc;
    color: var(--text);
}

button.danger {
    border: 1px solid #fecaca;
    background: #fee2e2;
    color: var(--danger);
}

button.danger:hover {
    background: #fecaca;
}

button.danger-soft {
    background: #fff1f2;
    color: #9f1239;
}

button.danger-soft:hover {
    background: #ffe4e6;
}

input,
select {
    width: 100%;
    min-height: 40px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 0 12px;
    background: white;
    color: var(--text);
}

input[type="file"] {
    min-height: auto;
    padding: 18px;
    border-style: dashed;
    background: #f8fbff;
}

label {
    display: block;
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 0.86rem;
    font-weight: 700;
}

img,
video,
canvas {
    max-width: 100%;
}

.shell {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 28px 0;
}

.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
}

.auth-panel {
    width: min(460px, 100%);
    padding: 28px;
}

.auth-logo {
    display: block;
    width: min(280px, 100%);
    height: auto;
    margin: 0 auto 18px;
}

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

.topbar h1 {
    margin: 0;
    font-size: 1.55rem;
    line-height: 1.15;
    max-width: 220px;
}

.brand-block {
    display: flex;
    align-items: center;
    gap: 14px;
    flex: 0 1 auto;
    min-width: 320px;
}

.brand-logo {
    width: 160px;
    max-width: 40vw;
    height: auto;
}

.eyebrow {
    margin: 0;
    color: var(--accent);
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
}

.token-box {
    display: grid;
    grid-template-columns: minmax(180px, 260px) auto;
    align-items: end;
    gap: 10px;
}

.session-box {
    flex: 1 1 620px;
    display: grid;
    grid-template-columns: minmax(120px, 140px) minmax(120px, auto) minmax(470px, auto);
    align-items: end;
    justify-content: end;
    gap: 12px;
    min-width: 0;
    padding: 8px;
    border: 1px solid #dbe4ef;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.78);
    box-shadow: 0 14px 34px rgba(15, 23, 42, 0.07);
}

.language-box,
.auth-language-box {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.language-select {
    min-width: 120px;
    min-height: 40px;
}

.session-box label {
    margin: 0 0 4px;
}

.session-user {
    margin: 0;
    color: var(--text);
    font-weight: 700;
    min-height: 40px;
    display: flex;
    align-items: center;
}

.session-box .actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 7px;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}

.session-box .actions form {
    margin: 0;
    display: flex;
}

.session-box .actions button {
    min-height: 36px;
    border-radius: 999px;
    padding: 0 12px;
    white-space: nowrap;
    font-size: 0.84rem;
    font-weight: 800;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.06);
}

.session-box .actions #aiCreatorOpen {
    background: #0f766e;
    color: #ffffff;
}

.session-box .actions #aiCreatorOpen:hover {
    background: #0d665f;
}

.session-box .actions #customDesignOpen {
    border: 1px solid #bfdbfe;
    background: #eff6ff;
    color: #1d4ed8;
}

.session-box .actions #customDesignOpen:hover {
    background: #dbeafe;
    color: #1e40af;
}

.session-box .actions #howToOpen {
    border: 1px solid #dbe4ef;
    background: #ffffff;
    color: #334155;
}

.session-box .actions #howToOpen:hover,
.session-box .actions form button.secondary:hover {
    background: #f1f5f9;
}

.session-box .actions #refreshAll {
    background: #2563eb;
    color: #ffffff;
    box-shadow: 0 10px 22px rgba(37, 99, 235, 0.22);
}

.session-box .actions form button.secondary {
    border: 1px solid #dbe4ef;
    background: #f8fafc;
    color: #475569;
}

.token-box label {
    grid-column: 1 / -1;
    margin-bottom: -2px;
}

.notice {
    margin-bottom: 16px;
    border: 1px solid #bfdbfe;
    border-radius: 6px;
    padding: 12px 14px;
    background: #eff6ff;
    color: #1e3a8a;
}

.notice.error {
    border-color: #fecaca;
    background: #fff1f2;
    color: #991b1b;
}

.layout {
    display: grid;
    grid-template-columns: 330px 1fr;
    gap: 18px;
    align-items: start;
}

.topbar > *,
.layout > *,
.workspace,
.panel,
.screen-title > *,
.panel-head > *,
.actions > *,
.media-row > *,
.media-picker-head > *,
.media-picker-actions > *,
.custom-sign-head > *,
.custom-template-head > *,
.howto-head > * {
    min-width: 0;
}

.workflow-strip {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    margin: 0 0 14px;
}

.workflow-strip div {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 38px;
    padding: 8px 10px;
    border: 1px solid #dbe4ef;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.86);
    color: #334155;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.05);
}

.workflow-strip strong {
    display: inline-grid;
    place-items: center;
    width: 24px;
    height: 24px;
    border-radius: 999px;
    background: #2563eb;
    color: #ffffff;
    font-size: 0.78rem;
    flex: 0 0 auto;
}

.workflow-strip span {
    min-width: 0;
    font-size: 0.8rem;
    font-weight: 800;
    line-height: 1.15;
}

.sidebar-stack {
    display: grid;
    gap: 18px;
}

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

.sidebar-stack .panel {
    overflow: hidden;
}

.sidebar-stack .panel.is-collapsed {
    min-height: 0;
}

.sidebar-stack .panel.is-collapsed > :not(.panel-head) {
    display: none !important;
}

.sidebar-stack .panel .panel-head {
    cursor: pointer;
    user-select: none;
}

.sidebar-stack .panel .panel-head::after {
    content: "+";
    display: inline-grid;
    width: 28px;
    height: 28px;
    flex: 0 0 auto;
    place-items: center;
    border: 1px solid #dbe4ef;
    border-radius: 999px;
    background: #f8fbff;
    color: #2563eb;
    font-size: 1.1rem;
    font-weight: 900;
    line-height: 1;
}

.sidebar-stack .panel:not(.is-collapsed) .panel-head::after {
    content: "-";
}

.screen-panel {
    min-height: 520px;
}

.group-panel {
    min-height: 260px;
}

.share-qr-panel {
    overflow: hidden;
}

.media-library-panel {
    padding-bottom: 14px;
    overflow: hidden;
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}

.media-library-copy {
    margin: 0;
    padding: 0 18px 12px;
    font-size: 0.86rem;
    line-height: 1.35;
}

.media-library-button {
    width: calc(100% - 36px);
    min-height: 36px;
    margin: 0 18px 8px;
    border-radius: 999px;
    background: #0f766e;
    box-shadow: 0 12px 24px rgba(15, 118, 110, 0.18);
}

.media-library-button:hover {
    background: #0d665f;
}

.consolidate-media-button {
    border: 1px solid #bfdbfe;
    background: #eff6ff;
    color: #1d4ed8;
    box-shadow: 0 10px 20px rgba(37, 99, 235, 0.08);
}

.consolidate-media-button:hover {
    background: #dbeafe;
    color: #1e40af;
}

.media-library-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 18px 0;
}

.media-library-summary span {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0 10px;
    border: 1px solid #ccfbf1;
    border-radius: 999px;
    background: #f0fdfa;
    color: #0f766e;
    font-size: 0.78rem;
    font-weight: 800;
}

.media-search-row {
    display: grid;
    grid-template-columns: minmax(120px, 180px) minmax(0, 1fr);
    align-items: center;
    gap: 12px;
    margin: 12px 0 10px;
    padding: 12px 14px;
    border: 1px solid #dbe4ef;
    border-radius: 14px;
    background: #f8fbff;
}

.media-search-row[hidden] {
    display: none;
}

.media-search-row label {
    margin: 0;
    color: #0f766e;
    font-size: 0.84rem;
    font-weight: 900;
}

.media-search-row input {
    min-height: 36px;
    border-radius: 999px;
    background: #ffffff;
}

.screen-search-box {
    display: grid;
    gap: 7px;
    padding: 12px;
    border-bottom: 1px solid var(--line);
    background: #f8fbff;
}

.screen-search-box label {
    margin: 0;
    color: #334155;
    font-size: 0.8rem;
    font-weight: 900;
}

.screen-search-box input {
    min-height: 38px;
    border-radius: 999px;
    background: #ffffff;
}

.share-qr-body {
    display: grid;
    justify-items: center;
    gap: 12px;
    padding: 18px;
    text-align: center;
}

#shareQrCanvas {
    width: min(184px, 100%);
    height: auto;
    padding: 10px;
    border: 1px solid #dbe4ef;
    border-radius: 12px;
    background: #ffffff;
    box-shadow: 0 16px 30px rgba(15, 23, 42, 0.08);
}

.share-qr-url {
    width: 100%;
    margin: 0;
    padding: 8px 10px;
    border-radius: 9px;
    background: #f8fafc;
    color: #475569;
    font-size: 0.78rem;
    line-height: 1.3;
    overflow-wrap: anywhere;
}

.share-qr-warning {
    margin: 0;
    padding: 10px 12px;
    border: 1px solid #fecdd3;
    border-radius: 10px;
    background: #fff1f2;
    color: #be123c;
    font-size: 0.86rem;
    line-height: 1.35;
    font-weight: 700;
}

#locations,
#groups,
#screens,
#users,
#groupScreens,
#locationPlaylist,
#playlist {
    overflow-y: scroll;
    scrollbar-width: thin;
    scrollbar-color: #94a3b8 #eef2f7;
}

#locations,
#groups,
#screens,
#users,
#groupScreens {
    max-height: 520px;
    padding-right: 8px;
}

#locations {
    min-height: 180px;
}

#groups {
    min-height: 120px;
}

#groupScreens {
    min-height: 220px;
}

#locationPlaylist,
#playlist {
    max-height: 520px;
    min-height: 220px;
    padding-right: 8px;
}

#locations::-webkit-scrollbar,
#groups::-webkit-scrollbar,
#screens::-webkit-scrollbar,
#users::-webkit-scrollbar,
#groupScreens::-webkit-scrollbar,
#locationPlaylist::-webkit-scrollbar,
#playlist::-webkit-scrollbar {
    width: 10px;
}

#locations::-webkit-scrollbar-track,
#groups::-webkit-scrollbar-track,
#screens::-webkit-scrollbar-track,
#users::-webkit-scrollbar-track,
#groupScreens::-webkit-scrollbar-track,
#locationPlaylist::-webkit-scrollbar-track,
#playlist::-webkit-scrollbar-track {
    background: #eef2f7;
    border-radius: 999px;
}

#locations::-webkit-scrollbar-thumb,
#groups::-webkit-scrollbar-thumb,
#screens::-webkit-scrollbar-thumb,
#users::-webkit-scrollbar-thumb,
#groupScreens::-webkit-scrollbar-thumb,
#locationPlaylist::-webkit-scrollbar-thumb,
#playlist::-webkit-scrollbar-thumb {
    background: #94a3b8;
    border-radius: 999px;
    border: 2px solid #eef2f7;
}

#locations::-webkit-scrollbar-thumb:hover,
#groups::-webkit-scrollbar-thumb:hover,
#screens::-webkit-scrollbar-thumb:hover,
#users::-webkit-scrollbar-thumb:hover,
#groupScreens::-webkit-scrollbar-thumb:hover,
#locationPlaylist::-webkit-scrollbar-thumb:hover,
#playlist::-webkit-scrollbar-thumb:hover {
    background: #64748b;
}

.workspace {
    min-height: 240px;
    padding: 18px 22px 22px;
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px;
    border-bottom: 1px solid var(--line);
}

.workspace .panel-head {
    padding: 18px 0 12px;
}

.panel-head h2,
.screen-title h2,
.empty h2 {
    margin: 0;
    font-size: 1.1rem;
}

.panel-head h2 {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.step-badge {
    display: inline-grid;
    place-items: center;
    width: 24px;
    height: 24px;
    border-radius: 999px;
    background: #2563eb;
    color: #ffffff;
    font-size: 0.78rem;
    font-weight: 900;
    line-height: 1;
}

.assign-help-panel {
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}

.assign-help-copy {
    margin: 0;
    padding: 0 18px 18px;
    font-size: 0.86rem;
    line-height: 1.4;
}

.optional-location-panel {
    opacity: 0.98;
}

.screen-list {
    display: grid;
    gap: 8px;
    padding: 12px;
}

.mini-form {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 12px;
    border-bottom: 1px solid var(--line);
}

.player-update-panel textarea {
    width: 100%;
    min-height: 86px;
    resize: vertical;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
    background: #ffffff;
    color: var(--text);
}

.player-update-ready {
    display: grid;
    gap: 8px;
    margin: 12px;
    border: 1px solid #bbf7d0;
    border-radius: 14px;
    padding: 12px;
    background: #ecfdf5;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.player-update-ready strong {
    color: #065f46;
    font-size: 0.94rem;
}

.player-update-ready p {
    margin: 0;
    color: #047857;
    font-size: 0.84rem;
    line-height: 1.35;
}

.player-update-ready button {
    min-height: 40px;
    border-radius: 999px;
    background: linear-gradient(135deg, #059669 0%, #0f766e 100%);
    color: #ffffff;
    box-shadow: 0 12px 22px rgba(5, 150, 105, 0.18);
}

.player-update-status {
    margin: 0;
    min-height: 20px;
    overflow-wrap: anywhere;
    font-size: 0.82rem;
}

.smtp-settings-form {
    gap: 10px;
}

.smtp-enable-row {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 10px 12px;
    border: 1px solid #dbeafe;
    border-radius: 12px;
    background: #eff6ff;
    color: #1e3a8a;
    font-weight: 800;
}

.smtp-enable-row input {
    width: 18px;
    height: 18px;
}

.smtp-grid,
.smtp-test-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 10px;
}

.smtp-settings-status {
    min-height: 18px;
    margin: 0;
    overflow-wrap: anywhere;
}

.auth-form {
    border-bottom: 0;
    padding: 0;
    margin-top: 18px;
}

.auth-link {
    display: inline-flex;
    justify-content: center;
    width: 100%;
    margin-top: 16px;
    color: #1d4ed8;
    font-weight: 800;
    text-decoration: none;
}

.auth-link:hover {
    text-decoration: underline;
}

.screen-item {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    background: #fbfdff;
    color: var(--text);
    text-align: left;
}

.screen-item:hover,
.screen-item.active {
    border-color: #93c5fd;
    background: #eff6ff;
}

.screen-item strong {
    display: block;
    margin-bottom: 5px;
}

.screen-item span {
    display: block;
    color: var(--muted);
    font-size: 0.86rem;
}

.screen-item .screen-approval-line {
    display: inline-flex;
    width: fit-content;
    margin-top: 8px;
    border-radius: 999px;
    padding: 4px 9px;
    background: #eef4ff;
    color: #1d4ed8;
    font-size: 0.72rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0;
}

.screen-item .screen-approval-line.pending {
    background: #fff7ed;
    color: #9a3412;
}

.screen-item .screen-approval-line.approved {
    background: #ecfdf5;
    color: #047857;
}

.screen-item .screen-approval-line.blocked {
    background: #fef2f2;
    color: #b91c1c;
}

.empty {
    display: grid;
    min-height: 145px;
    place-content: center;
    text-align: center;
    padding: 22px 18px;
}

.empty p {
    max-width: 390px;
    color: var(--muted);
}

.compact-empty {
    min-height: 90px;
    padding: 14px;
}

.screen-title {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.muted {
    margin: 6px 0 0;
    color: var(--muted);
}

.code-pill {
    min-width: 112px;
    border: 1px solid #bbf7d0;
    border-radius: 8px;
    padding: 12px 16px;
    background: #ecfdf5;
    color: #065f46;
    font-size: 1.45rem;
    font-weight: 900;
    text-align: center;
}

.screen-approval-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin: -4px 0 16px;
    border: 1px solid #dbe4ef;
    border-radius: 14px;
    padding: 13px;
    background: #f8fbff;
}

.screen-approval-box.pending {
    border-color: #fed7aa;
    background: #fff7ed;
}

.screen-approval-box.approved {
    border-color: #bbf7d0;
    background: #f0fdf4;
}

.screen-approval-box.blocked {
    border-color: #fecaca;
    background: #fef2f2;
}

.screen-approval-box strong {
    display: block;
    color: var(--text);
}

.screen-approval-box p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 0.86rem;
}

.screen-approval-box .actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.screen-approval-box .actions button {
    min-height: 38px;
    border-radius: 999px;
    padding: 0 14px;
}

.row-form {
    display: grid;
    grid-template-columns: 1fr 150px 190px auto;
    gap: 10px;
    margin-bottom: 16px;
}

.screen-row-form {
    grid-template-columns: minmax(170px, 1fr) minmax(112px, 140px) minmax(126px, 156px) minmax(140px, 170px) minmax(140px, 170px);
    align-items: center;
    padding: 12px;
    border: 1px solid #dbe4ef;
    border-radius: 14px;
    background: #f8fbff;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85);
}

.screen-row-form button[type="submit"] {
    grid-column: -2 / -1;
    justify-self: stretch;
    width: 100%;
    min-height: 40px;
    border: 1px solid #1d4ed8;
    border-radius: 999px;
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: #ffffff;
    box-shadow: 0 12px 22px rgba(37, 99, 235, 0.22);
    white-space: nowrap;
}

.screen-row-form button[type="submit"]:hover {
    background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
    box-shadow: 0 14px 26px rgba(29, 78, 216, 0.26);
}

.upload-area {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
    background: #fbfdff;
}

.upload-options {
    display: grid;
    grid-template-columns: minmax(150px, 200px) minmax(90px, 120px) auto;
    align-items: end;
    gap: 10px;
    margin-top: 14px;
}

.upload-status {
    margin-top: 12px;
}

.upload-warning {
    margin: 10px 0 0;
    color: var(--warning);
    font-size: 0.9rem;
    font-weight: 600;
}

.upload-compatibility {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 0.88rem;
}

.upload-status-bar {
    width: 100%;
    height: 10px;
    overflow: hidden;
    border-radius: 999px;
    background: #dbe7f5;
}

.upload-status-fill {
    width: 0;
    height: 100%;
    background: linear-gradient(90deg, #059669, #2563eb);
    transition: width 120ms ease;
}

.custom-sign {
    margin-top: 20px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfdff;
    overflow: hidden;
}

.custom-sign-top {
    margin-top: 0;
    margin-bottom: 24px;
}

.ai-creator-top-button {
    border-color: #a7f3d0;
    background: #ecfdf5;
    color: #047857;
    font-weight: 800;
}

.ai-creator-page {
    margin-bottom: 24px;
    border: 1px solid #a7f3d0;
    border-radius: 8px;
    background: linear-gradient(180deg, #f0fdfa, #ffffff);
    overflow: hidden;
}

.ai-creator-page[hidden] {
    display: none;
}

.ai-creator-head {
    padding: 16px;
    align-items: flex-start;
}

.ai-creator-head h2 {
    margin: 4px 0 0;
}

.ai-creator-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.75fr);
    gap: 16px;
    padding: 0 16px 16px;
}

.ai-creator-card {
    display: grid;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
}

.ai-creator-card label {
    margin: 0;
    font-weight: 800;
}

.ai-creator-card textarea {
    width: 100%;
    min-height: 136px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    resize: vertical;
    font: inherit;
}

.ai-creator-upload,
.ai-creator-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.ai-creator-image-list {
    display: grid;
    gap: 8px;
}

.ai-creator-image-row {
    display: grid;
    grid-template-columns: 64px minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafc;
}

.ai-creator-image-row img {
    width: 64px;
    height: 48px;
    border-radius: 6px;
    object-fit: cover;
    background: #e5e7eb;
}

.ai-creator-image-row strong,
.ai-creator-image-row span {
    display: block;
}

.ai-creator-image-row span {
    color: var(--muted);
    font-size: 0.84rem;
}

.ai-creator-options {
    grid-template-columns: 1fr;
    border-bottom: 0;
    padding: 0;
}

.ai-creator-options select,
.ai-creator-options input {
    width: 100%;
}

.error-text {
    color: #b91c1c !important;
    font-weight: 700;
}

.custom-sign-head {
    padding: 22px 26px 16px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
}

.workspace .custom-sign-head {
    padding: 22px 26px 16px;
}

.custom-sign-head h2 {
    margin: 0;
    font-size: 1.38rem;
    line-height: 1.15;
}

.custom-sign-head .muted {
    margin: 10px 0 0;
    max-width: 640px;
    line-height: 1.45;
}

.custom-sign-head .actions {
    flex: 0 0 auto;
    display: grid;
    grid-template-columns: repeat(3, minmax(92px, auto));
    gap: 7px;
    padding: 7px;
    border: 1px solid #dbe4ef;
    border-radius: 16px;
    background: rgba(248, 250, 252, 0.94);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.custom-sign-head .actions button {
    min-height: 34px;
    border-radius: 999px;
    padding: 0 11px;
    white-space: nowrap;
    font-size: 0.82rem;
    font-weight: 800;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.06);
}

.custom-sign-head .actions button.secondary {
    border: 1px solid #e2e8f0;
    background: #ffffff;
    color: #334155;
}

.custom-sign-head .actions button.secondary:hover {
    background: #f1f5f9;
}

.custom-sign-head .actions button.danger {
    grid-column: span 3;
}

.custom-sign-grid {
    display: block;
    padding: 0 16px 16px;
}

.custom-sign-tabs {
    display: inline-flex;
    gap: 6px;
    padding: 6px;
    margin: 0 18px 14px;
    border: 1px solid #dbe4ef;
    border-radius: 999px;
    background: #f8fafc;
}

.custom-sign-tabs button {
    min-height: 34px;
    padding: 0 16px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: #475569;
    font-size: 0.88rem;
    font-weight: 800;
    box-shadow: none;
}

.custom-sign-tabs button.active {
    background: #0f766e;
    color: white;
    box-shadow: 0 10px 20px rgba(15, 118, 110, 0.18);
}

.custom-template-panel {
    margin: 0 18px 14px;
    padding: 16px;
    border: 1px solid #dbe4ef;
    border-radius: 14px;
    background: linear-gradient(180deg, #ffffff, #f8fbff);
}

.custom-template-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
}

.custom-template-head h3 {
    margin: 0;
    font-size: 1.02rem;
}

.custom-template-head .muted {
    margin: 6px 0 0;
}

.custom-template-upload {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    min-width: 220px;
}

.custom-template-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 12px;
    max-height: 390px;
    overflow-y: auto;
    padding-right: 6px;
}

.custom-template-card {
    display: grid;
    gap: 10px;
    padding: 10px;
    border: 1px solid #dbe4ef;
    border-radius: 12px;
    background: #ffffff;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
}

.custom-template-preview {
    width: 100%;
    padding: 0;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
    background: #f1f5f9;
    aspect-ratio: 16 / 9;
    box-shadow: none;
}

.custom-template-preview img,
.custom-template-preview video {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
}

.custom-template-info {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.custom-template-info strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.custom-template-info span {
    color: var(--muted);
    font-size: 0.82rem;
}

.custom-template-use {
    min-height: 34px;
    border-radius: 999px;
    font-size: 0.84rem;
    font-weight: 800;
}

.custom-template-empty {
    grid-column: 1 / -1;
}

.custom-sign-stage,
.custom-sign-sidebar {
    display: grid;
    gap: 14px;
}

.custom-sign-toolbar {
    display: grid;
    grid-template-columns: minmax(280px, 0.92fr) minmax(320px, 1fr);
    align-items: start;
    gap: 14px;
    padding: 0 18px;
}

.custom-tool-card {
    display: grid;
    gap: 10px;
    padding: 14px;
    border: 1px solid #dbe4ef;
    border-radius: 12px;
    background: rgba(248, 250, 252, 0.88);
}

.custom-tool-card > label,
.custom-duration-row label {
    margin: 0;
}

.custom-color-row,
.custom-duration-row,
.custom-button-row,
.custom-save-row {
    display: flex;
    align-items: center;
    gap: 9px;
}

.custom-color-row,
.custom-button-row,
.custom-save-row {
    flex-wrap: wrap;
}

.custom-button-row button {
    flex: 1 1 140px;
    min-height: 36px;
    border-radius: 999px;
    font-size: 0.86rem;
}

.custom-save-row {
    align-items: stretch;
}

.custom-save-row #customSignSave {
    flex: 1 1 180px;
}

.custom-sign-toolbar input[type="color"] {
    width: 60px;
    min-width: 60px;
    padding: 4px;
}

.custom-sign-toolbar input:disabled,
.custom-sign-toolbar select:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.custom-sign-toolbar input[type="number"] {
    width: 100px;
    min-width: 100px;
}

#customSignTarget {
    min-width: 260px;
    max-width: 100%;
}

.custom-tool-output #customSignTarget {
    min-width: 0;
    width: 100%;
}

.custom-sign-mode {
    display: inline-flex;
    align-items: center;
    min-height: 38px;
    padding: 0 12px;
    border: 1px solid #bfdbfe;
    border-radius: 999px;
    background: #eff6ff;
    color: #1d4ed8;
    font-size: 0.88rem;
    font-weight: 700;
}

.custom-sign-canvas-wrap {
    display: grid;
    place-items: center;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: linear-gradient(180deg, #eef4fb, #f8fbff);
    min-height: 620px;
}

#customSignCanvas {
    width: 100%;
    max-width: 1120px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: white;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
    cursor: grab;
    touch-action: none;
}

#customSignCanvas:active {
    cursor: grabbing;
}

.custom-sign-layers,
.custom-sign-controls {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: white;
    padding: 14px;
}

.custom-sign-bottom {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 18px;
    padding: 0 16px 16px;
}

.custom-sign-bottom > * {
    min-width: 0;
}

.custom-sign-layers h3,
.custom-sign-controls h3 {
    margin: 0 0 12px;
    font-size: 0.98rem;
}

.layer-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 8px;
}

.layer-item {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fbff;
    color: var(--text);
    text-align: left;
}

.layer-item.active,
.layer-item:hover {
    border-color: #93c5fd;
    background: #eff6ff;
}

.layer-item strong,
.layer-item span {
    display: block;
}

.layer-item strong {
    display: flex;
    align-items: center;
    gap: 8px;
}

.layer-item span {
    color: var(--muted);
    font-size: 0.84rem;
}

.layer-lock-icon {
    display: inline-block;
    width: 12px;
    height: 10px;
    border: 2px solid #2563eb;
    border-radius: 2px;
    position: relative;
    flex: 0 0 auto;
}

.layer-lock-icon::before {
    content: "";
    position: absolute;
    left: 1px;
    top: -8px;
    width: 6px;
    height: 6px;
    border: 2px solid #2563eb;
    border-bottom: 0;
    border-radius: 999px 999px 0 0;
}

.custom-sign-form {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px 14px;
    padding: 0;
    border-bottom: 0;
}

.custom-sign-form > label {
    margin: 0;
    align-self: end;
}

.custom-sign-form textarea {
    width: 100%;
    min-height: 110px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 10px 12px;
    resize: vertical;
    font: inherit;
}

#customSignTextControls,
#customSignImageControls,
#customSignShapeControls {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px 14px;
    grid-column: 1 / -1;
}

#customSignTextControls[hidden],
#customSignImageControls[hidden],
#customSignShapeControls[hidden] {
    display: none;
}

#customSignTextControls label,
#customSignImageControls label,
#customSignShapeControls label {
    margin: 0;
    align-self: end;
}

label[for="customSignText"],
#customSignText {
    grid-column: 1 / -1;
}

#customSignImageControls label[for="customSignImageFit"],
#customSignImageFit {
    grid-column: span 2;
}

#customSignShapeControls label,
#customSignShapeControls select,
#customSignShapeControls input {
    grid-column: span 2;
}

.playlist-head {
    margin-top: 20px;
}

@media (min-width: 1100px) {
    .custom-sign-bottom {
        grid-template-columns: minmax(280px, 0.9fr) minmax(0, 1.6fr);
        align-items: start;
    }
}

@media (max-width: 1100px) {
    .shell {
        width: min(1180px, calc(100% - 24px));
        padding: 22px 0;
    }

    .topbar {
        align-items: stretch;
        flex-direction: column;
        gap: 14px;
    }

    .topbar h1 {
        max-width: none;
    }

    .brand-block {
        min-width: 0;
    }

    .session-box {
        flex: 0 1 auto;
        width: 100%;
        grid-template-columns: minmax(112px, 140px) minmax(120px, 1fr) minmax(0, auto);
        justify-content: stretch;
    }

    .session-box .actions {
        justify-content: flex-start;
    }

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

    .sidebar-stack {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        align-items: start;
    }

    .workspace,
    .screen-panel,
    .group-panel {
        min-height: auto;
    }

    .screen-row-form {
        grid-template-columns: repeat(3, minmax(150px, 1fr));
    }
}

@media (max-width: 980px) {
    .workflow-strip {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .custom-sign-head {
        flex-direction: column;
    }

    .custom-sign-head .actions {
        width: 100%;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .custom-sign-head .actions button.danger {
        grid-column: 1 / -1;
    }

    .custom-sign-toolbar {
        grid-template-columns: minmax(0, 1fr);
        padding: 0 12px;
    }

    .ai-creator-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .custom-sign-canvas-wrap {
        min-height: 420px;
    }

    .custom-sign-form,
    #customSignTextControls,
    #customSignImageControls,
    #customSignShapeControls {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 940px) {
    .sidebar-stack {
        grid-template-columns: minmax(0, 1fr);
    }

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

    .session-box .actions {
        grid-column: 1 / -1;
    }

    .screen-title,
    .screen-approval-box,
    .panel-head,
    .media-picker-head,
    .media-picker-actions,
    .image-preview-head,
    .custom-preview-head,
    .howto-head {
        align-items: stretch;
        flex-direction: column;
    }

    .row-form,
    .screen-row-form,
    .upload-options {
        grid-template-columns: minmax(0, 1fr);
    }

    .playlist-head .actions,
    .screen-approval-box .actions,
    .screen-title .actions {
        justify-content: flex-start;
        width: 100%;
    }

    .code-pill {
        width: 100%;
    }
}

@media (max-width: 640px) {
    .shell {
        width: min(100% - 20px, 1180px);
        padding: 16px 0;
    }

    .workflow-strip {
        grid-template-columns: minmax(0, 1fr);
    }

    .session-box {
        grid-template-columns: minmax(0, 1fr);
    }

    .session-box .actions {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
    }

    .session-box .actions form,
    .session-box .actions button {
        width: 100%;
    }

    .workspace {
        padding: 14px;
    }

    .custom-sign-head,
    .workspace .custom-sign-head {
        padding: 16px;
    }

    .custom-sign-head .actions {
        grid-template-columns: minmax(0, 1fr);
    }

    .custom-sign-head .actions button.danger {
        grid-column: auto;
    }

    .custom-sign-tabs {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        margin: 0 12px 12px;
        border-radius: 14px;
    }

    .custom-template-panel {
        margin: 0 12px 12px;
        padding: 12px;
    }

    .custom-template-head,
    .custom-template-upload,
    .media-target-actions {
        align-items: stretch;
        flex-direction: column;
        min-width: 0;
    }

    .custom-template-upload button,
    .media-target-actions button {
        width: 100%;
    }

    .custom-sign-form,
    #customSignTextControls,
    #customSignImageControls,
    #customSignShapeControls {
        grid-template-columns: minmax(0, 1fr);
    }

    .custom-sign-canvas-wrap {
        min-height: 320px;
        padding: 12px;
    }

    .bulk-duration,
    .duration-editor {
        width: 100%;
        flex-wrap: wrap;
    }

    .bulk-duration input,
    .duration-editor input {
        flex: 1 1 96px;
    }
}

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

.bulk-duration {
    display: flex;
    align-items: center;
    gap: 8px;
}

.bulk-duration input {
    width: 96px;
    min-width: 96px;
}

.screen-duration-tool {
    padding: 6px 8px;
    border: 1px solid #dbeafe;
    border-radius: 999px;
    background: #f8fbff;
}

.screen-duration-tool label {
    margin: 0;
    color: #334155;
    font-size: 0.8rem;
    font-weight: 850;
}

.screen-duration-tool input {
    width: 76px;
    min-width: 76px;
    min-height: 34px;
}

.playlist-controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
    min-width: 340px;
}

.duration-editor {
    display: flex;
    align-items: center;
    gap: 8px;
}

.duration-editor input {
    width: 86px;
    min-width: 86px;
}

.playlist-readonly-note {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 0 12px;
    border: 1px solid #fde68a;
    border-radius: 999px;
    background: #fffbeb;
    color: #92400e;
    font-size: 0.82rem;
    font-weight: 850;
}

.playlist {
    display: grid;
    gap: 10px;
    padding-top: 14px;
}

.media-row {
    display: grid;
    grid-template-columns: 72px minmax(220px, 1fr) minmax(340px, auto);
    align-items: start;
    gap: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    background: #ffffff;
}

.media-row.selectable {
    grid-template-columns: 42px 72px minmax(220px, 1fr) minmax(340px, auto);
}

.media-row.selected {
    border-color: #93c5fd;
    background: #f8fbff;
    box-shadow: 0 12px 26px rgba(37, 99, 235, 0.08);
}

.media-select-box {
    display: grid;
    place-items: center;
    width: 38px;
    height: 54px;
    margin: 0;
    cursor: pointer;
}

.media-select-box input {
    width: 20px;
    height: 20px;
    min-height: 0;
    accent-color: #2563eb;
    cursor: pointer;
}

.media-selection-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin: 10px 0 0;
    padding: 12px 14px;
    border: 1px solid #bfdbfe;
    border-radius: 14px;
    background: #eff6ff;
}

.media-selection-bar[hidden] {
    display: none;
}

.media-selection-bar span {
    color: #1d4ed8;
    font-size: 0.86rem;
    font-weight: 850;
}

.media-selection-bar button {
    min-height: 34px;
    border-radius: 999px;
    font-size: 0.84rem;
}

.media-picker-modal {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(15, 23, 42, 0.44);
}

.media-picker-dialog {
    display: grid;
    gap: 14px;
    width: min(980px, 96vw);
    max-height: min(760px, 92vh);
    padding: 18px;
    overflow: hidden;
    border: 1px solid #dbe4ef;
    border-radius: 18px;
    background: #ffffff;
    box-shadow: 0 28px 70px rgba(15, 23, 42, 0.24);
}

.media-picker-head,
.media-picker-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.media-picker-head h3 {
    margin: 2px 0 4px;
}

.media-picker-tools {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) 220px;
    gap: 10px;
    align-items: end;
    padding: 12px;
    border: 1px solid #dbeafe;
    border-radius: 14px;
    background: #f8fbff;
}

.media-picker-tools label {
    display: grid;
    gap: 6px;
    margin: 0;
    color: #334155;
    font-size: 0.82rem;
    font-weight: 800;
}

.media-picker-hint {
    margin: -4px 2px 0;
    color: var(--muted);
    font-size: 0.84rem;
}

.media-picker-list {
    display: grid;
    gap: 9px;
    min-height: 180px;
    max-height: 420px;
    overflow: auto;
    padding-right: 4px;
}

.media-picker-item {
    display: grid;
    grid-template-columns: 26px 72px minmax(0, 1fr);
    align-items: center;
    gap: 12px;
    margin: 0;
    padding: 10px;
    border: 1px solid #dbe4ef;
    border-radius: 14px;
    background: #ffffff;
    cursor: pointer;
    transition: background 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.media-picker-item:hover,
.media-picker-item.selected {
    border-color: #93c5fd;
    background: #f8fbff;
}

.media-picker-item.selected {
    box-shadow: inset 4px 0 0 #2563eb;
}

.media-picker-item input[type="checkbox"] {
    width: 20px;
    height: 20px;
    min-height: 0;
    accent-color: #2563eb;
}

.media-picker-thumb {
    display: grid;
    width: 72px;
    height: 54px;
    place-items: center;
    overflow: hidden;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: #e8eef8;
    color: var(--primary);
    font-size: 0.72rem;
    font-weight: 900;
}

.media-picker-thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.media-picker-copy {
    display: grid;
    gap: 4px;
    min-width: 0;
}

.media-picker-copy strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.media-picker-copy span,
.media-picker-count {
    color: var(--muted);
    font-size: 0.84rem;
}

.media-picker-actions {
    padding-top: 4px;
}

.media-picker-assign {
    min-width: 180px;
}

.thumb {
    display: grid;
    width: 72px;
    height: 54px;
    place-items: center;
    overflow: hidden;
    border-radius: 6px;
    background: #e8eef8;
    color: var(--primary);
    font-size: 0.78rem;
    font-weight: 800;
}

.thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.thumb-clickable {
    cursor: zoom-in;
}

.thumb-clickable:hover {
    outline: 2px solid #93c5fd;
    outline-offset: 2px;
}

.media-copy {
    min-width: 0;
    display: grid;
    gap: 4px;
    padding-top: 2px;
}

.media-row strong {
    display: block;
    font-size: 0.96rem;
    line-height: 1.3;
    overflow-wrap: break-word;
    word-break: normal;
}

.media-row span {
    color: var(--muted);
    font-size: 0.84rem;
    line-height: 1.35;
}

.user-row {
    grid-template-columns: 58px minmax(0, 1fr);
    align-items: start;
    gap: 12px;
    padding: 12px;
    border-color: #dbe4ef;
    border-radius: 14px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
}

.user-avatar {
    display: grid;
    width: 58px;
    height: 58px;
    place-items: center;
    border: 1px solid #dbeafe;
    border-radius: 13px;
    background: linear-gradient(135deg, #eff6ff 0%, #e0f2fe 100%);
    color: #2563eb;
    font-size: 0.78rem;
    font-weight: 900;
    letter-spacing: 0.04em;
}

.user-copy {
    min-width: 0;
    padding-top: 2px;
}

.user-row strong {
    overflow-wrap: anywhere;
    word-break: normal;
    white-space: normal;
    line-height: 1.25;
    font-size: 0.98rem;
}

.user-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 7px;
    color: #64748b;
    font-size: 0.82rem;
    line-height: 1.2;
}

.user-email {
    margin-top: 6px;
    color: #475569;
    font-size: 0.78rem;
    line-height: 1.25;
    overflow-wrap: anywhere;
}

.role-pill {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 0 9px;
    border: 1px solid #dbeafe;
    border-radius: 999px;
    background: #eff6ff;
    color: #1d4ed8;
    font-size: 0.74rem;
    font-weight: 800;
    text-transform: uppercase;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: #94a3b8;
}

.status-dot.is-active {
    background: #10b981;
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.12);
}

.status-dot.is-inactive {
    background: #f43f5e;
    box-shadow: 0 0 0 4px rgba(244, 63, 94, 0.12);
}

.user-row .actions {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
    gap: 8px;
    width: 100%;
    margin-top: 2px;
    padding: 8px;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    background: rgba(241, 245, 249, 0.76);
}

.user-row .actions button {
    min-height: 38px;
    border: 1px solid transparent;
    border-radius: 11px;
    padding: 0 10px;
    font-size: 0.84rem;
    font-weight: 800;
    line-height: 1.1;
    white-space: nowrap;
    box-shadow: none;
    transition: background 140ms ease, border-color 140ms ease, color 140ms ease, transform 140ms ease;
}

.user-row .actions button.secondary {
    background: #ffffff;
    color: #334155;
    border-color: #dbe4ef;
}

.user-row .actions button.secondary:first-child {
    background: #eff6ff;
    color: #1d4ed8;
    border-color: #bfdbfe;
}

.user-row .actions button.secondary:hover {
    background: #eaf2ff;
    border-color: #93c5fd;
    color: #1e40af;
}

.user-row .actions button.danger {
    grid-column: 1 / -1;
    background: #fff1f2;
    color: #be123c;
    border-color: #fecdd3;
}

.user-row .actions button.danger:hover {
    background: #ffe4e6;
    border-color: #fda4af;
    color: #9f1239;
}

.media-target-modal {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(15, 23, 42, 0.35);
}

.media-target-dialog {
    width: min(100%, 420px);
    display: grid;
    gap: 14px;
    padding: 18px;
    border-radius: 12px;
    background: #ffffff;
    box-shadow: 0 18px 45px rgba(15, 23, 42, 0.22);
}

.media-target-dialog h3 {
    margin: 0;
}

.media-target-dialog p {
    margin: 0;
    color: var(--muted);
}

.media-confirm-label {
    margin: 0;
}

.media-confirm-input {
    width: 100%;
    min-height: 40px;
    border-radius: 10px;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

.media-target-select {
    width: 100%;
}

.media-target-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.image-preview-modal {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(15, 23, 42, 0.58);
}

.image-preview-dialog {
    width: min(96vw, 1180px);
    max-height: 92vh;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 14px;
    padding: 16px;
    border-radius: 10px;
    background: #ffffff;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.28);
}

.image-preview-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
}

.image-preview-head h3,
.image-preview-head p {
    margin: 0;
}

.image-preview-head p {
    margin-top: 4px;
    color: var(--muted);
    font-size: 0.88rem;
}

.image-preview-frame {
    min-height: 0;
    display: grid;
    place-items: center;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #0f172a;
}

.image-preview-frame img {
    max-width: 100%;
    max-height: 78vh;
    object-fit: contain;
}

.custom-preview-modal {
    position: fixed;
    inset: 0;
    z-index: 72;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(15, 23, 42, 0.68);
}

.custom-preview-modal[hidden] {
    display: none;
}

.custom-preview-dialog {
    width: min(1180px, 96vw);
    max-height: 92vh;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 14px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #ffffff;
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.30);
}

.custom-preview-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
}

.custom-preview-head h2,
.custom-preview-head p {
    margin: 0;
}

.custom-preview-head h2 {
    margin-top: 3px;
}

.custom-preview-frame {
    min-height: 0;
    display: grid;
    place-items: center;
    overflow: auto;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #0f172a;
}

#customPreviewCanvas {
    width: 100%;
    max-width: 1080px;
    height: auto;
    border-radius: 8px;
    background: #ffffff;
}

.howto-modal {
    position: fixed;
    inset: 0;
    z-index: 70;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(15, 23, 42, 0.52);
}

.howto-modal[hidden] {
    display: none;
}

.howto-dialog {
    width: min(1080px, 96vw);
    max-height: 90vh;
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr);
    gap: 16px;
    padding: 22px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.22);
}

.howto-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
}

.howto-head h2 {
    margin: 2px 0 4px;
    font-size: 1.65rem;
}

.howto-head p {
    margin: 0;
    color: var(--muted);
}

.howto-search {
    width: 100%;
    min-height: 46px;
    padding: 0 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafc;
    font: inherit;
}

.howto-body {
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(240px, 0.75fr) minmax(0, 1.55fr);
    gap: 18px;
}

.howto-topics,
.howto-content {
    min-height: 0;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.howto-topics {
    padding: 8px;
}

.howto-topic {
    width: 100%;
    display: block;
    padding: 12px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: var(--text);
    text-align: left;
    cursor: pointer;
}

.howto-topic:hover,
.howto-topic.active {
    border-color: #b7d4ff;
    background: #eef6ff;
}

.howto-topic strong,
.howto-content strong {
    display: block;
}

.howto-topic span {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-size: 0.86rem;
    line-height: 1.35;
}

.howto-content {
    padding: 22px;
}

.howto-content h3 {
    margin: 0 0 8px;
    font-size: 1.35rem;
}

.howto-content p {
    color: var(--muted);
}

.howto-mini-grid,
.howto-visuals {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 16px 0;
}

.howto-mini {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    min-width: 74px;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafc;
    color: var(--text);
    font-size: 0.86rem;
    font-weight: 700;
    white-space: nowrap;
}

.howto-mini.primary,
.howto-mini-primary {
    border-color: var(--blue);
    background: var(--blue);
    color: #fff;
}

.howto-mini.danger,
.howto-mini-danger {
    border-color: #fecaca;
    background: #fee2e2;
    color: #991b1b;
}

.howto-mini.field,
.howto-mini-field {
    min-width: 150px;
    justify-content: flex-start;
    color: var(--muted);
    font-weight: 600;
}

.howto-steps {
    margin: 0;
    padding-left: 22px;
}

.howto-steps li {
    margin: 0 0 12px;
    line-height: 1.5;
}

.howto-empty {
    display: grid;
    min-height: 260px;
    place-items: center;
    color: var(--muted);
    text-align: center;
}

@media (max-width: 820px) {
    .topbar,
    .screen-title {
        align-items: stretch;
        flex-direction: column;
    }

    .brand-block {
        min-width: 0;
    }

    .session-box {
        width: 100%;
        grid-template-columns: 1fr;
        justify-content: stretch;
    }

    .session-box .actions {
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    .token-box,
    .layout,
    .custom-sign-grid,
    .row-form,
    .upload-options,
    .media-row {
        grid-template-columns: 1fr;
    }

    .media-row.selectable {
        grid-template-columns: 1fr;
    }

    .media-select-box {
        width: 100%;
        height: auto;
        justify-content: start;
    }

    .media-picker-modal {
        padding: 12px;
    }

    .media-picker-dialog {
        padding: 14px;
    }

    .media-picker-head,
    .media-picker-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .media-picker-tools,
    .media-picker-item {
        grid-template-columns: 1fr;
    }

    .media-picker-thumb {
        width: 88px;
        height: 66px;
    }

    .playlist-controls {
        min-width: 0;
        justify-content: flex-start;
    }

    .thumb {
        width: 88px;
        height: 66px;
    }

    .howto-dialog {
        padding: 16px;
    }

    .howto-head {
        flex-direction: column;
    }

    .custom-preview-head {
        flex-direction: column;
    }

    .howto-body {
        grid-template-columns: 1fr;
    }

    .howto-topics {
        max-height: 210px;
    }

    .workspace,
    .screen-panel {
        min-height: auto;
    }

    .brand-block {
        flex-direction: column;
        align-items: flex-start;
    }

    .brand-logo {
        width: 180px;
    }

    .code-pill {
        width: 100%;
    }
}

/* Responsive polish for tablets and phones. Keep controls usable without changing behavior. */
@media (max-width: 1220px) {
    .shell {
        width: min(100% - 24px, 1180px);
    }

    .topbar {
        gap: 14px;
    }

    .brand-block {
        min-width: 260px;
    }

    .brand-logo {
        width: 145px;
    }

    .session-box {
        flex: 1 1 520px;
        grid-template-columns: minmax(112px, 130px) minmax(120px, 0.7fr) minmax(300px, 1fr);
    }

    .session-box .actions {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
        width: 100%;
    }

    .session-box .actions form,
    .session-box .actions button {
        width: 100%;
    }

    .session-box .actions button {
        padding: 0 10px;
        font-size: 0.8rem;
    }
}

@media (max-width: 1080px) {
    .topbar {
        align-items: stretch;
        flex-direction: column;
    }

    .brand-block {
        width: 100%;
        min-width: 0;
    }

    .session-box {
        width: 100%;
        grid-template-columns: minmax(118px, 150px) minmax(160px, 1fr);
    }

    .session-box .actions {
        grid-column: 1 / -1;
    }

    .playlist-head,
    .screen-title,
    .panel-head,
    .media-selection-bar {
        align-items: stretch;
    }

    .playlist-controls,
    .playlist-head .actions,
    .screen-title .actions {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
        width: 100%;
        min-width: 0;
        justify-content: stretch;
    }

    .playlist-controls button,
    .playlist-head .actions button,
    .screen-title .actions button,
    .playlist-controls .duration-editor,
    .playlist-controls .screen-duration-tool {
        width: 100%;
    }

    .screen-duration-tool,
    .duration-editor,
    .bulk-duration {
        justify-content: space-between;
        border-radius: 14px;
    }

    .media-row,
    .media-row.selectable {
        grid-template-columns: 78px minmax(0, 1fr);
    }

    .media-row > .actions,
    .media-row > .duration-editor,
    .media-row > .media-row-actions {
        grid-column: 1 / -1;
    }

    .media-row .actions,
    .media-row .duration-editor {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
        width: 100%;
    }
}

@media (max-width: 760px) {
    .shell {
        width: min(100% - 16px, 1180px);
        padding: 12px 0;
    }

    .topbar h1 {
        font-size: 1.25rem;
        max-width: none;
    }

    .brand-block {
        display: grid;
        grid-template-columns: 110px minmax(0, 1fr);
        align-items: center;
        gap: 10px;
    }

    .brand-logo {
        width: 110px;
        max-width: 110px;
    }

    .session-box {
        grid-template-columns: minmax(0, 1fr);
        padding: 10px;
        border-radius: 12px;
    }

    .session-user {
        min-height: 32px;
        overflow-wrap: anywhere;
    }

    .layout,
    .sidebar-stack,
    .custom-sign-grid,
    .custom-sign-bottom,
    .screen-row-form,
    .row-form,
    .upload-options,
    .media-picker-tools {
        grid-template-columns: minmax(0, 1fr) !important;
    }

    .workspace,
    .panel {
        padding-left: 12px;
        padding-right: 12px;
    }

    .workflow-strip div {
        border-radius: 14px;
    }

    .playlist-head,
    .screen-title,
    .panel-head,
    .media-selection-bar {
        flex-direction: column;
    }

    .playlist-controls,
    .playlist-head .actions,
    .screen-title .actions,
    .media-selection-bar {
        grid-template-columns: minmax(0, 1fr);
    }

    .playlist-controls button,
    .playlist-head .actions button,
    .screen-title .actions button,
    .media-selection-bar button,
    .custom-sign-head .actions button,
    .custom-button-row button,
    .custom-save-row button {
        width: 100%;
        min-height: 40px;
    }

    .media-row,
    .media-row.selectable {
        grid-template-columns: 64px minmax(0, 1fr);
        gap: 10px;
        padding: 10px;
    }

    .thumb,
    .media-picker-thumb {
        width: 64px;
        height: 50px;
    }

    .media-select-box {
        grid-column: 1 / -1;
        width: 100%;
        height: 34px;
        place-items: start;
    }

    .media-row .actions,
    .media-row .duration-editor,
    .media-target-actions,
    .custom-template-upload,
    .custom-template-head {
        grid-template-columns: minmax(0, 1fr);
        align-items: stretch;
    }

    .duration-editor input,
    .bulk-duration input,
    .screen-duration-tool input {
        width: 100%;
        min-width: 0;
    }

    .custom-sign-toolbar {
        padding: 0 8px;
    }

    .custom-tool-card {
        padding: 12px;
    }

    .custom-sign-tabs {
        margin-left: 8px;
        margin-right: 8px;
    }

    .custom-sign-canvas-wrap {
        min-height: 300px;
        padding: 8px;
    }
}

@media (max-width: 420px) {
    button,
    input,
    select {
        min-height: 42px;
    }

    .brand-block {
        grid-template-columns: minmax(0, 1fr);
    }

    .brand-logo {
        width: 132px;
        max-width: 55vw;
    }

    .session-box .actions,
    .playlist-controls,
    .media-row .actions,
    .custom-sign-head .actions {
        grid-template-columns: minmax(0, 1fr);
    }

    .media-row,
    .media-row.selectable {
        grid-template-columns: minmax(0, 1fr);
    }

    .thumb,
    .media-picker-thumb {
        width: 86px;
        height: 64px;
    }

    .user-row {
        grid-template-columns: 48px minmax(0, 1fr);
        gap: 10px;
    }

    .user-avatar {
        width: 48px;
        height: 48px;
        border-radius: 11px;
        font-size: 0.7rem;
    }

    .user-row .actions {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* Tablet/laptop safe scrolling: keep final action buttons reachable. */
@media (max-width: 1180px), (max-height: 820px) {
    html,
    body {
        min-height: 100%;
        overflow-y: auto;
    }

    .shell {
        padding-bottom: max(96px, env(safe-area-inset-bottom));
    }

    .layout,
    .workspace,
    .sidebar-stack,
    .panel {
        min-height: 0;
    }

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

    .workspace {
        overflow: visible;
    }

    .sidebar-stack .panel {
        max-height: none;
        overflow: visible;
    }

    #playlist,
    #locationPlaylist,
    #screens,
    #users,
    #groups,
    #locations {
        max-height: min(56vh, 520px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

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

    .screen-row-form button[type="submit"] {
        grid-column: 1 / -1;
    }

    .panel-head,
    .playlist-head {
        gap: 12px;
    }

    .panel-head .actions,
    .playlist-head .actions {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
        width: 100%;
    }

    .panel-head .actions button,
    .playlist-head .actions button,
    .panel-head .actions form,
    .playlist-head .actions form {
        width: 100%;
    }
}

@media (max-width: 900px), (max-height: 720px) {
    .shell {
        width: min(100% - 18px, 1180px);
        padding-top: 12px;
        padding-bottom: 120px;
    }

    .workspace,
    .panel {
        padding: 12px;
        overflow: visible;
    }

    .screen-row-form,
    .custom-sign-form,
    #customSignTextControls,
    #customSignImageControls,
    #customSignShapeControls {
        grid-template-columns: minmax(0, 1fr) !important;
    }

    .screen-row-form select,
    .screen-row-form input,
    .screen-row-form button,
    .custom-sign-form input,
    .custom-sign-form select,
    .custom-sign-form textarea,
    .custom-sign-form button {
        width: 100%;
        min-width: 0;
    }

    .custom-sign-canvas-wrap {
        min-height: clamp(260px, 48vh, 520px);
    }

    #playlist,
    #locationPlaylist,
    #screens,
    #users,
    #groups,
    #locations {
        max-height: min(48vh, 460px);
    }

    .media-row,
    .media-row.selectable {
        grid-template-columns: minmax(72px, 96px) minmax(0, 1fr);
    }

    .media-row .actions,
    .media-row .duration-editor,
    .media-row .media-row-actions {
        grid-column: 1 / -1;
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
        width: 100%;
    }
}
