:root {
  --bg: #07111f;
  --bg-soft: #0b1828;
  --surface: rgba(15, 31, 49, 0.88);
  --surface-solid: #102136;
  --surface-hover: #162b43;
  --line: rgba(153, 189, 216, 0.16);
  --text: #eff8ff;
  --muted: #92a9ba;
  --primary: #62e8c7;
  --primary-strong: #24caa4;
  --accent: #6b91ff;
  --danger: #ff7083;
  --warning: #f8c35d;
  --success: #61e6a3;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.24);
  --radius: 20px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --viewport-height: 100vh;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

:root[data-theme="light"] {
  --bg: #f3f7f8;
  --bg-soft: #eaf1f3;
  --surface: rgba(255, 255, 255, 0.92);
  --surface-solid: #ffffff;
  --surface-hover: #f3f8f8;
  --line: rgba(20, 55, 76, 0.12);
  --text: #102537;
  --muted: #657c8d;
  --primary: #087f6a;
  --primary-strong: #066b5a;
  --accent: #3c62d8;
  --danger: #c83e54;
  --warning: #9a6a07;
  --success: #0b7d4d;
  --shadow: 0 22px 60px rgba(32, 65, 79, 0.12);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; background: var(--bg); color: var(--text); }
body {
  background-image:
    radial-gradient(circle at 82% -8%, rgba(85, 130, 255, 0.18), transparent 34rem),
    radial-gradient(circle at 8% 105%, rgba(69, 229, 190, 0.12), transparent 36rem);
  background-attachment: fixed;
}
button, input, select, textarea { font: inherit; }
button { color: inherit; }
a { color: var(--primary); }
.hidden { display: none !important; }

.app-shell { min-height: var(--viewport-height); display: grid; grid-template-columns: 250px minmax(0, 1fr); }
.sidebar {
  position: sticky; top: 0; height: 100vh; padding: calc(24px + var(--safe-top)) 18px 24px;
  border-right: 1px solid var(--line); background: rgba(4, 14, 25, 0.7); backdrop-filter: blur(24px);
  display: flex; flex-direction: column; z-index: 10;
}
:root[data-theme="light"] .sidebar { background: rgba(247, 251, 251, 0.8); }
.brand { display: flex; gap: 12px; align-items: center; padding: 6px 10px 26px; }
.brand-mark { width: 38px; height: 38px; border-radius: 13px; display: grid; place-items: center; color: #07111f; background: linear-gradient(135deg, #67efd0, #6b90ff); box-shadow: 0 8px 30px rgba(73, 207, 186, .24); }
.brand span:last-child { display: grid; line-height: 1.1; }
.brand b { letter-spacing: .15em; }
.brand small { margin-top: 5px; color: var(--muted); font-size: 10px; letter-spacing: .08em; }
.desktop-nav { display: grid; gap: 4px; overflow-y: auto; padding-right: 2px; }
.nav-button { border: 0; background: transparent; padding: 11px 12px; border-radius: 13px; text-align: left; cursor: pointer; display: flex; gap: 11px; align-items: center; color: var(--muted); transition: .18s ease; }
.nav-button:hover { color: var(--text); background: var(--surface-hover); }
.nav-button.active { color: var(--text); background: linear-gradient(90deg, rgba(92, 231, 199, .16), rgba(102, 139, 255, .08)); box-shadow: inset 3px 0 var(--primary); }
.nav-icon { width: 22px; text-align: center; }
.sidebar-account { margin-top: auto; border-top: 1px solid var(--line); padding: 16px 10px 0; color: var(--muted); font-size: 12px; }
.sidebar-account strong { display: block; margin-bottom: 4px; color: var(--text); font-size: 14px; }

.workspace { min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 8; min-height: calc(74px + var(--safe-top)); padding: calc(14px + var(--safe-top)) 30px 14px;
  display: flex; align-items: center; gap: 13px; border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 76%, transparent); backdrop-filter: blur(22px);
}
.topbar-title { min-width: 0; display: grid; margin-right: auto; }
.topbar-title small { color: var(--muted); font-size: 11px; }
.topbar-title strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-button { border: 1px solid var(--line); width: 38px; height: 38px; border-radius: 12px; background: var(--surface); cursor: pointer; }
.status-pill { border: 1px solid var(--line); border-radius: 999px; padding: 6px 10px; font-size: 11px; white-space: nowrap; }
.status-pill.success { color: var(--success); background: color-mix(in srgb, var(--success) 10%, transparent); }
.status-pill.warning { color: var(--warning); }
.status-pill.danger { color: var(--danger); }
.status-pill.neutral { color: var(--muted); }

.content { width: min(1400px, 100%); margin: 0 auto; padding: 30px 30px 90px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 24px; }
.page-head h1 { margin: 0 0 7px; font-size: clamp(26px, 3vw, 40px); letter-spacing: -.035em; }
.page-head p { margin: 0; color: var(--muted); line-height: 1.65; }
.actions { display: flex; flex-wrap: wrap; gap: 9px; }
.button { border: 1px solid var(--line); border-radius: 13px; padding: 10px 15px; background: var(--surface-solid); cursor: pointer; transition: .16s ease; font-weight: 650; }
.button:hover { transform: translateY(-1px); border-color: color-mix(in srgb, var(--primary) 50%, var(--line)); }
.button.primary { color: #061a18; background: linear-gradient(135deg, #69efd1, #75d8ba); border-color: transparent; }
.button.accent { color: white; background: linear-gradient(135deg, #557cff, #806cff); border-color: transparent; }
.button.danger { color: var(--danger); background: color-mix(in srgb, var(--danger) 8%, var(--surface-solid)); }
.button.ghost { background: transparent; }
.button:disabled { opacity: .45; cursor: not-allowed; transform: none; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 22px; }
.metric-card, .panel, .bot-card, .feature-card {
  border: 1px solid var(--line); background: var(--surface); backdrop-filter: blur(18px); border-radius: var(--radius); box-shadow: var(--shadow);
}
.metric-card { padding: 18px; min-height: 122px; position: relative; overflow: hidden; }
.metric-card::after { content: ""; position: absolute; width: 95px; height: 95px; right: -28px; top: -35px; border-radius: 50%; background: color-mix(in srgb, var(--accent) 13%, transparent); }
.metric-card small { color: var(--muted); }
.metric-card strong { display: block; margin: 13px 0 5px; font-size: 28px; }
.metric-card span { font-size: 12px; color: var(--muted); }
.panel { padding: 22px; margin-bottom: 18px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.panel-head h2, .panel h2 { margin: 0; font-size: 18px; }
.panel-subtitle { color: var(--muted); font-size: 13px; margin-top: 5px; }
.split-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(280px, .8fr); gap: 18px; }
.card-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.bot-card, .feature-card { padding: 19px; box-shadow: none; }
.bot-card-head { display: flex; align-items: center; gap: 13px; }
.bot-avatar { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 15px; background: linear-gradient(135deg, rgba(98,232,199,.25), rgba(107,145,255,.24)); color: var(--primary); font-weight: 800; }
.bot-card h3, .feature-card h3 { margin: 0; font-size: 16px; }
.bot-card p, .feature-card p { color: var(--muted); font-size: 13px; line-height: 1.65; }
.bot-meta { display: flex; flex-wrap: wrap; gap: 7px; margin: 14px 0; }
.tag { border-radius: 999px; background: var(--bg-soft); border: 1px solid var(--line); color: var(--muted); padding: 5px 8px; font-size: 11px; }
.tag.on { color: var(--success); }
.tag.off { color: var(--danger); }
.card-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 12px 0; }
.card-stats div { background: var(--bg-soft); border-radius: 11px; padding: 9px; }
.card-stats small { display: block; color: var(--muted); font-size: 10px; }
.card-stats strong { display: block; margin-top: 3px; }

.filter-bar { display: flex; flex-wrap: wrap; gap: 9px; margin-bottom: 16px; }
.input, .select { min-width: 0; border: 1px solid var(--line); border-radius: 12px; background: var(--bg-soft); color: var(--text); padding: 10px 12px; outline: none; }
.input:focus, .select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 12%, transparent); }
.filter-bar .input { flex: 1 1 220px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 15px; }
table { width: 100%; border-collapse: collapse; min-width: 720px; }
th, td { padding: 13px 14px; text-align: left; border-bottom: 1px solid var(--line); font-size: 13px; vertical-align: middle; }
th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
tr:last-child td { border-bottom: 0; }
.row-actions { display: flex; gap: 7px; }
.text-button { border: 0; background: transparent; color: var(--primary); cursor: pointer; padding: 3px; }
.text-button.danger { color: var(--danger); }
.empty-state { padding: 46px 20px; text-align: center; border: 1px dashed var(--line); border-radius: var(--radius); }
.empty-state .symbol { width: 64px; height: 64px; display: grid; place-items: center; margin: 0 auto 16px; border-radius: 22px; background: color-mix(in srgb, var(--primary) 12%, var(--surface)); font-size: 28px; }
.empty-state h2 { margin: 0 0 8px; }
.empty-state p { color: var(--muted); line-height: 1.7; max-width: 540px; margin: 0 auto 18px; }
.notice { border-left: 3px solid var(--accent); border-radius: 10px; background: color-mix(in srgb, var(--accent) 8%, var(--surface)); padding: 12px 14px; color: var(--muted); line-height: 1.55; font-size: 13px; }
.muted { color: var(--muted); }
.notice.warning { border-color: var(--warning); }
.notice.danger { border-color: var(--danger); }
.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; margin: -4px 0 18px; scrollbar-width: none; }
.tab { border: 1px solid var(--line); border-radius: 999px; background: transparent; padding: 8px 13px; white-space: nowrap; cursor: pointer; color: var(--muted); }
.tab.active { background: var(--surface-solid); color: var(--text); border-color: color-mix(in srgb, var(--primary) 50%, var(--line)); }
.kv-list { display: grid; }
.kv-row { display: grid; grid-template-columns: minmax(120px, .6fr) minmax(0, 1.4fr); gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.kv-row:last-child { border-bottom: 0; }
.kv-row span:first-child { color: var(--muted); }
.danger-zone { border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); }
.todo-list { display: grid; gap: 10px; }
.todo-item { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 15px; border: 1px solid var(--line); border-left: 3px solid var(--warning); border-radius: 14px; background: var(--bg-soft); }
.todo-item.critical { border-left-color: var(--danger); }
.todo-item h3 { margin: 8px 0 4px; font-size: 15px; }
.todo-item p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.batch-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 12px 0 16px; }
.selection-box { width: 18px; height: 18px; accent-color: var(--primary); }
.broadcast-preview { max-height: 360px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; border: 1px solid var(--line); border-radius: 14px; background: var(--bg-soft); color: var(--text); padding: 15px; line-height: 1.65; }
.settings-list { display: grid; gap: 2px; }
.setting-toggle { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.setting-toggle:last-child { border-bottom: 0; }
.setting-toggle span { display: grid; gap: 5px; }
.setting-toggle small { color: var(--muted); }
.setting-toggle input { width: 20px; height: 20px; accent-color: var(--primary); }
.health-critical { border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); }
.health-attention { border-color: color-mix(in srgb, var(--warning) 45%, var(--line)); }

.loading-state { min-height: 65vh; display: grid; place-content: center; text-align: center; }
.loading-state h1 { font-size: 22px; margin: 20px 0 8px; }
.loading-state p { color: var(--muted); margin: 0; }
.orbital-loader { width: 58px; height: 58px; margin: auto; border: 1px solid var(--line); border-radius: 50%; position: relative; animation: spin 1.7s linear infinite; }
.orbital-loader::before, .orbital-loader i { content: ""; position: absolute; border-radius: 50%; background: var(--primary); }
.orbital-loader::before { width: 11px; height: 11px; top: -5px; left: 23px; box-shadow: 0 0 20px var(--primary); }
.orbital-loader i { width: 8px; height: 8px; bottom: 8px; right: 4px; background: var(--accent); }
@keyframes spin { to { transform: rotate(360deg); } }

.modal-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.58); backdrop-filter: blur(7px); display: grid; place-items: center; padding: 18px; }
.modal { width: min(540px, 100%); max-height: min(780px, calc(100vh - 36px)); overflow-y: auto; border: 1px solid var(--line); border-radius: 24px; background: var(--surface-solid); box-shadow: 0 30px 90px rgba(0,0,0,.42); padding: 23px; }
.modal h2 { margin: 0 0 8px; }
.modal p { color: var(--muted); line-height: 1.65; }
.modal label { display: grid; gap: 7px; margin: 16px 0; color: var(--muted); font-size: 13px; }
.modal .input { width: 100%; color: var(--text); }
.choice { width: 100%; text-align: left; border: 1px solid var(--line); border-radius: 16px; background: var(--bg-soft); padding: 15px; margin: 8px 0; cursor: pointer; }
.choice strong { display: block; margin-bottom: 5px; }
.choice small { color: var(--muted); }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 20px; }
.toast-root { position: fixed; z-index: 60; right: 20px; top: calc(18px + var(--safe-top)); display: grid; gap: 9px; }
.toast { width: min(380px, calc(100vw - 32px)); padding: 13px 15px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface-solid); box-shadow: var(--shadow); font-size: 13px; animation: toast-in .2s ease-out; }
.toast.error { border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); }
@keyframes toast-in { from { transform: translateY(-8px); opacity: 0; } }
.mobile-nav { display: none; }

@media (max-width: 1050px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .card-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .split-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { display: none; }
  .topbar { min-height: calc(64px + var(--safe-top)); padding: calc(9px + var(--safe-top)) 14px 9px; }
  .topbar-title strong { font-size: 15px; }
  .status-pill { display: none; }
  .content { padding: 22px 14px calc(92px + var(--safe-bottom)); }
  .page-head { align-items: stretch; flex-direction: column; margin-bottom: 18px; }
  .page-head h1 { font-size: 27px; }
  .actions .button { flex: 1; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
  .metric-card { min-height: 104px; padding: 14px; }
  .metric-card strong { font-size: 23px; }
  .card-grid { grid-template-columns: 1fr; }
  .panel { padding: 17px; border-radius: 17px; }
  .mobile-nav { position: fixed; display: grid; grid-template-columns: repeat(5, minmax(0,1fr)); left: 0; right: 0; bottom: 0; z-index: 20; border-top: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(24px); padding: 7px 6px calc(7px + var(--safe-bottom)); }
  .mobile-nav .nav-button { display: grid; justify-items: center; gap: 3px; padding: 5px 2px; font-size: 10px; text-align: center; box-shadow: none; }
  .mobile-nav .nav-icon { font-size: 18px; }
  .mobile-nav .nav-button.active { background: transparent; color: var(--primary); }
  .table-wrap { border: 0; overflow: visible; }
  table, thead, tbody, tr, th, td { display: block; min-width: 0; }
  thead { display: none; }
  tr { border: 1px solid var(--line); border-radius: 14px; background: var(--bg-soft); padding: 10px; margin-bottom: 10px; }
  td { display: flex; justify-content: space-between; gap: 14px; border: 0; padding: 7px 5px; text-align: right; }
  td::before { content: attr(data-label); color: var(--muted); text-align: left; }
  .row-actions { justify-content: flex-end; }
  .todo-item { align-items: stretch; flex-direction: column; }
  .batch-bar .button { flex: 1; }
  .modal-backdrop { align-items: end; padding: 0; }
  .modal { width: 100%; max-height: calc(92vh - var(--safe-top)); border-radius: 24px 24px 0 0; padding-bottom: calc(22px + var(--safe-bottom)); }
  .toast-root { right: 16px; top: calc(12px + var(--safe-top)); }
}

@media (max-width: 390px) {
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .metric-card span { display: none; }
  .button { padding-left: 12px; padding-right: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

/* V1.1-R1: mobile containment, shared pagination and presentation components. */
html, body { width: 100%; max-width: 100%; overflow-x: hidden; overflow-x: clip; }
.app-shell, .workspace, .content, .panel, .metric-card, .bot-card, .feature-card,
.page-head, .filter-bar, .split-grid, .card-grid, .kv-list, .kv-row,
.todo-item, .batch-bar, .modal, .choice, td, td > *, .row-actions { min-width: 0; }
.kv-row span:last-child, td, .notice, .panel-subtitle, .muted, .bot-card p,
.feature-card p, .choice small, .pagination-summary {
  overflow-wrap: anywhere;
  word-break: break-word;
}
.long-value { min-width: 0; max-width: 100%; overflow-wrap: anywhere; word-break: break-word; }
.truncate-value { display: block; min-width: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.pagination {
  display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin: 18px 0 4px;
}
.pagination .button { padding: 8px 10px; min-width: 38px; }
.pagination .page-number.primary { color: #061a18; }
.pagination-summary { color: var(--muted); font-size: 12px; margin-left: 4px; }
.page-jump { width: 88px; flex: 0 0 88px; }

.folder-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.folder-card {
  border: 1px solid var(--line); border-radius: 16px; background: var(--bg-soft);
  padding: 16px; cursor: pointer; min-width: 0; transition: .16s ease;
}
.folder-card:hover { border-color: color-mix(in srgb, var(--primary) 45%, var(--line)); transform: translateY(-1px); }
.folder-card h3 { margin: 0 0 7px; font-size: 15px; overflow-wrap: anywhere; }
.folder-card p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.folder-card .folder-count { display: inline-block; margin-top: 10px; font-weight: 750; color: var(--primary); }
.breadcrumb { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin: -8px 0 16px; color: var(--muted); font-size: 12px; }
.breadcrumb button { border: 0; background: none; color: var(--primary); padding: 0; cursor: pointer; }

.banner-stage { margin: 0 0 22px; min-width: 0; overflow: hidden; border-radius: var(--radius); }
.banner-card {
  position: relative; width: 100%; aspect-ratio: 16 / 6.8; min-height: 140px; max-height: 320px;
  overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
  cursor: pointer; box-shadow: var(--shadow);
}
.banner-card img { width: 100%; height: 100%; object-fit: cover; object-position: center; display: block; }
.banner-card.pure-image img { object-position: center; }
.banner-card.has-copy::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(180deg, rgba(0,0,0,.02) 28%, rgba(0,0,0,.18) 58%, rgba(0,0,0,.72) 100%); }
.banner-card.no-image { display: grid; align-content: end; background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 35%, var(--surface-solid)), color-mix(in srgb, var(--primary) 18%, var(--surface-solid))); }
.banner-overlay { position: absolute; z-index: 1; inset: auto 0 0; padding: 30px 24px 20px; background: transparent; color: white; text-shadow: 0 1px 3px rgba(0,0,0,.42); }
.banner-card.no-image .banner-overlay { position: static; background: transparent; }
.banner-overlay strong { display: block; max-width: 86%; font-size: clamp(18px, 3vw, 30px); line-height: 1.2; overflow-wrap: anywhere; }
.banner-overlay span { display: block; max-width: 88%; margin-top: 7px; font-size: 13px; line-height: 1.45; opacity: .94; overflow-wrap: anywhere; }
.banner-dots { display: flex; justify-content: center; gap: 6px; margin-top: 9px; }
.banner-dot { width: 7px; height: 7px; border-radius: 50%; border: 0; padding: 0; background: var(--muted); opacity: .45; }
.banner-dot.active { opacity: 1; background: var(--primary); }

html.keyboard-open .mobile-nav { transform: translateY(120%); pointer-events: none; }
html.keyboard-open .content { padding-bottom: 24px; }

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

@media (max-width: 760px) {
  body { background-attachment: scroll; }
  .content { width: 100%; max-width: 100%; overflow-x: hidden; overflow-x: clip; }
  .folder-grid { grid-template-columns: 1fr; }
  .kv-row { grid-template-columns: minmax(92px, .58fr) minmax(0, 1.42fr); gap: 10px; }
  td { min-width: 0; max-width: 100%; overflow-wrap: anywhere; word-break: break-word; }
  td > * { max-width: 68%; overflow-wrap: anywhere; }
  td::before { flex: 0 0 30%; }
  .row-actions { flex-wrap: wrap; }
  .pagination { gap: 6px; }
  .pagination .button { flex: 0 0 auto; padding: 8px 9px; }
  .pagination-summary { flex: 1 0 100%; order: 20; margin-top: 3px; }
  .page-jump { order: 21; }
  .pagination .page-jump + .button { order: 22; }
  .banner-card { aspect-ratio: 16 / 7.2; min-height: 132px; max-height: 230px; border-radius: 17px; }
  .banner-overlay { padding: 24px 17px 15px; }
  .modal-backdrop { height: var(--viewport-height); min-height: 320px; top: var(--visual-offset-top, 0px); bottom: auto; }
  .modal { max-height: calc(var(--viewport-height) - 12px - var(--safe-top)); overscroll-behavior: contain; }
}

/* V1.1-R1 completion: folder buttons and banner carousel/admin containment. */
.folder-open { width: 100%; display: flex; align-items: center; gap: 12px; min-width: 0; border: 0; background: transparent; color: inherit; text-align: left; padding: 0; cursor: pointer; }
.folder-open > div:last-child { min-width: 0; flex: 1; }
.folder-icon { width: 42px; height: 42px; flex: 0 0 42px; display: grid; place-items: center; border-radius: 13px; background: color-mix(in srgb, var(--primary) 12%, var(--surface)); color: var(--primary); font-size: 20px; }
.banner-track { display: flex; width: 100%; min-width: 0; transition: transform .35s ease; will-change: transform; }
.banner-track > .banner-card { flex: 0 0 100%; min-width: 100%; box-shadow: none; }
.banner-admin-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.banner-admin-grid > * { min-width: 0; }
.banner-admin-grid .banner-card { min-height: 118px; aspect-ratio: 16 / 7; }
.banner-image-failed { display: none !important; }
.banner-card.clickable { cursor: pointer; }
.banner-card:not(.clickable) { cursor: default; }
@media (max-width: 760px) { .banner-admin-grid { grid-template-columns: 1fr; } }

/* Telegram iOS WebView first-focus hardening. 16px prevents iOS input auto-zoom. */
@media (max-width: 760px) {
  .input, .select, textarea, input, select { font-size: 16px; }
  html.ios-telegram body { background-attachment: scroll !important; }
  html.ios-telegram .modal-backdrop { backdrop-filter: none; -webkit-backdrop-filter: none; }
  html.ios-telegram.keyboard-open .topbar,
  html.ios-telegram.keyboard-open .mobile-nav { backdrop-filter: none; -webkit-backdrop-filter: none; }
}

/* OWNER platform-resource cards reuse the established bot-card system. */
.owner-resource-identity { min-width: 0; flex: 1; }
.owner-resource-identity h3 { margin: 0; overflow-wrap: anywhere; }
.owner-resource-identity p { margin: 4px 0 0; color: var(--muted); overflow-wrap: anywhere; }
.owner-resource-stats { grid-template-columns: repeat(3, minmax(0,1fr)); }
@media (max-width: 390px) { .owner-resource-stats { grid-template-columns: 1fr 1fr; } }
/* Long operational values must wrap inside metrics instead of stretching the viewport. */
.metric-card strong, .metric-card span { min-width: 0; max-width: 100%; overflow-wrap: anywhere; word-break: break-word; }

/* V1.1-R2: Telegram iOS whole-site first-focus/lifecycle hardening. */
.banner-upload-field { display: grid; gap: 10px; margin: 16px 0; color: var(--muted); }
.banner-upload-field > strong { color: var(--text); font-size: 14px; }
.banner-file-input { width: 100%; max-width: 100%; color: var(--text); font-size: 16px; }
.banner-upload-preview { width: 100%; min-height: 92px; display: grid; place-items: center; overflow: hidden; border: 1px dashed var(--line); border-radius: 15px; background: var(--bg-soft); }
.banner-upload-preview img { display: block; width: 100%; max-height: 280px; object-fit: cover; aspect-ratio: 16 / 7; }

@media (hover: none) and (pointer: coarse) and (max-width: 760px) {
  .mobile-nav .nav-button:hover:not(.active),
  .mobile-nav .nav-button:focus:not(.active),
  .mobile-nav .nav-button:focus-visible:not(.active) {
    color: var(--muted);
    background: transparent;
    box-shadow: none;
    outline: none;
  }
  .mobile-nav .nav-button.active,
  .mobile-nav .nav-button.active:hover,
  .mobile-nav .nav-button.active:focus,
  .mobile-nav .nav-button.active:focus-visible {
    color: var(--primary);
    background: transparent;
    box-shadow: none;
    outline: none;
  }
}

@media (max-width: 760px) {
  html.ios-telegram .topbar,
  html.ios-telegram .mobile-nav,
  html.ios-telegram .metric-card,
  html.ios-telegram .panel,
  html.ios-telegram .bot-card,
  html.ios-telegram .feature-card,
  html.ios-telegram .modal,
  html.ios-telegram .modal-backdrop {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }
  html.ios-telegram.ios-input-arming body,
  html.ios-telegram.ios-input-active body,
  html.ios-telegram.keyboard-open body {
    background-image: none !important;
    background-attachment: scroll !important;
  }
  html.ios-telegram .modal-backdrop {
    top: 0 !important;
    bottom: auto !important;
    height: var(--viewport-height) !important;
    min-height: 320px;
  }
  html.ios-telegram .modal {
    max-height: calc(var(--viewport-height) - 12px - var(--safe-top)) !important;
  }
}


/* V1.1-R3: final Telegram iOS form-focus stabilization.
   Keep layout topology stable while the native keyboard animates. */
@media (max-width: 760px) {
  html.ios-telegram.ios-input-arming .topbar,
  html.ios-telegram.ios-input-active .topbar,
  html.ios-telegram.keyboard-open .topbar {
    position: sticky !important;
    top: 0 !important;
  }
  html.ios-telegram.ios-input-arming .mobile-nav,
  html.ios-telegram.ios-input-active .mobile-nav {
    display: grid !important;
    visibility: visible !important;
    opacity: 1 !important;
    transform: none !important;
    pointer-events: auto !important;
  }
  html.ios-telegram.keyboard-open .mobile-nav {
    display: grid !important;
    visibility: hidden !important;
    opacity: 0 !important;
    transform: none !important;
    pointer-events: none !important;
  }
  html.ios-telegram.ios-input-arming .content,
  html.ios-telegram.ios-input-active .content {
    min-height: 0 !important;
    padding-bottom: calc(92px + var(--safe-bottom)) !important;
  }
  html.ios-telegram.keyboard-open .content {
    min-height: 0 !important;
    padding-bottom: 24px !important;
  }
  html.ios-telegram.ios-input-arming .filter-bar,
  html.ios-telegram.ios-input-active .filter-bar,
  html.ios-telegram.keyboard-open .filter-bar,
  html.ios-telegram.ios-input-arming .pagination,
  html.ios-telegram.ios-input-active .pagination,
  html.ios-telegram.keyboard-open .pagination {
    position: relative;
    z-index: 2;
    visibility: visible !important;
    opacity: 1 !important;
    contain: layout style;
  }
  html.ios-telegram .filter-bar > *,
  html.ios-telegram .pagination > * {
    visibility: visible !important;
    opacity: 1 !important;
  }
  html.ios-telegram input,
  html.ios-telegram textarea,
  html.ios-telegram select,
  html.ios-telegram button {
    -webkit-tap-highlight-color: transparent;
  }
  html.ios-telegram .workspace,
  html.ios-telegram .content {
    transform: none !important;
  }
  html.ios-telegram.ios-suspended body,
  html.ios-telegram.ios-resuming body {
    background-image: none !important;
    background-attachment: scroll !important;
  }
  html.ios-telegram.ios-resuming .workspace,
  html.ios-telegram.ios-resuming .content {
    min-height: 0 !important;
    transform: none !important;
    visibility: visible !important;
    opacity: 1 !important;
  }
  html.ios-telegram.ios-resuming .filter-bar,
  html.ios-telegram.ios-resuming .pagination,
  html.ios-telegram.ios-resuming .actions {
    visibility: visible !important;
    opacity: 1 !important;
  }
}


/* V1.1-R4-F3: keyboard-safe Banner sheets and a stable carousel clipping frame. */
.banner-stage {
  position: relative;
  min-width: 0;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--line) 88%, transparent);
  border-radius: 22px;
  box-shadow: 0 18px 52px rgba(0, 0, 0, .22);
  background: var(--surface-solid);
  margin-bottom: 28px;
}
.banner-track {
  display: flex;
  width: 100%;
  min-width: 0;
  overflow: visible;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
  transform: translate3d(0, 0, 0);
  transition: none;
  will-change: transform;
}
.banner-track.is-ready { transition: transform .35s ease; }
.banner-track > .banner-card {
  border: 0;
  border-radius: 0;
}
.banner-card {
  isolation: isolate;
  aspect-ratio: 16 / 7.15;
  min-height: 150px;
  max-height: 340px;
  border-radius: 22px;
  background: #0a1523;
  box-shadow: 0 18px 52px rgba(0, 0, 0, .20);
}
.banner-card::before {
  content: "";
  position: absolute;
  z-index: 3;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.06);
}
.banner-card img { transition: transform .45s ease; }
.banner-card.clickable:hover img { transform: scale(1.012); }
.banner-card.has-copy::after {
  z-index: 1;
  background:
    linear-gradient(90deg, rgba(2,8,16,.78) 0%, rgba(2,8,16,.34) 47%, rgba(2,8,16,.05) 78%),
    linear-gradient(0deg, rgba(2,8,16,.72) 0%, rgba(2,8,16,.12) 58%, rgba(2,8,16,.02) 100%);
}
.banner-badge {
  position: absolute;
  z-index: 4;
  top: 15px;
  left: 15px;
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 4px 9px;
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 999px;
  background: rgba(3, 10, 18, .46);
  color: rgba(255,255,255,.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .06em;
}
.banner-card.pure-image .banner-badge { opacity: .72; }
.banner-overlay {
  z-index: 2;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  padding: 54px 26px 22px;
  text-shadow: 0 2px 8px rgba(0,0,0,.46);
}
.banner-copy { min-width: 0; max-width: min(78%, 720px); }
.banner-copy strong {
  display: block;
  max-width: 100%;
  font-size: clamp(20px, 3vw, 31px);
  line-height: 1.12;
  letter-spacing: -.025em;
  overflow-wrap: anywhere;
}
.banner-copy span {
  display: block;
  max-width: 100%;
  margin-top: 7px;
  color: rgba(255,255,255,.88);
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.banner-cta {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 50%;
  background: rgba(5, 13, 22, .42);
  color: white;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  font-size: 18px;
  font-weight: 800;
}
.banner-pure-cta {
  position: absolute;
  z-index: 4;
  right: 16px;
  bottom: 16px;
}
.banner-dots {
  position: absolute;
  z-index: 6;
  top: 14px;
  right: 14px;
  display: flex;
  align-items: center;
  gap: 5px;
  margin: 0;
  padding: 6px 8px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 999px;
  background: rgba(3,10,18,.42);
  backdrop-filter: blur(9px);
  -webkit-backdrop-filter: blur(9px);
}
.banner-dot { width: 6px; height: 6px; background: rgba(255,255,255,.66); opacity: .48; transition: width .18s ease, opacity .18s ease, background .18s ease; }
.banner-dot.active { width: 16px; border-radius: 999px; opacity: 1; background: var(--primary); }

.banner-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.banner-admin-card { padding: 16px; }
.banner-admin-preview { overflow: hidden; border-radius: 17px; }
.banner-admin-preview .banner-card { min-height: 0; max-height: none; aspect-ratio: 16 / 7.4; border-radius: 17px; box-shadow: none; }
.banner-admin-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 14px 0 6px; }
.banner-admin-heading > div { min-width: 0; display: grid; gap: 4px; }
.banner-admin-heading strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.banner-admin-heading small { color: var(--muted); font-size: 11px; }
.banner-admin-meta { display: flex; flex-wrap: wrap; gap: 7px 12px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.banner-admin-actions { margin-top: 14px; }

.banner-editor-modal { width: min(720px, 100%); }
.banner-editor-modal,
.banner-delete-modal {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.banner-editor-modal > h2,
.banner-delete-modal > h2 { flex: 0 0 auto; }
.banner-editor {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  display: grid;
  gap: 14px;
  padding-right: 2px;
}
.banner-editor-section { border: 1px solid var(--line); border-radius: 18px; background: var(--bg-soft); padding: 16px; }
.banner-editor-head { margin-bottom: 13px; }
.banner-editor-head h3 { margin: 0; font-size: 16px; }
.banner-editor-head p { margin: 5px 0 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.banner-mode-switch { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; margin-bottom: 13px; }
.banner-mode-option {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface-solid);
  color: var(--text);
  padding: 13px;
  text-align: left;
  cursor: pointer;
}
.banner-mode-option strong { display: block; font-size: 14px; }
.banner-mode-option small { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; line-height: 1.45; }
.banner-mode-option.active { border-color: color-mix(in srgb, var(--primary) 65%, var(--line)); background: color-mix(in srgb, var(--primary) 9%, var(--surface-solid)); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 16%, transparent); }
.banner-copy-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.banner-copy-fields label, .banner-schedule-grid label { margin: 0; }
.banner-upload-field { margin: 0 0 12px; padding: 12px; border: 1px dashed var(--line); border-radius: 14px; background: color-mix(in srgb, var(--surface-solid) 56%, transparent); }
.banner-file-input::file-selector-button { margin-right: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-solid); color: var(--text); padding: 8px 11px; cursor: pointer; }
.banner-upload-state { font-size: 11px; line-height: 1.55; }
.banner-editor-preview { min-height: 142px; margin-top: 10px; }
.banner-editor-preview .banner-card { min-height: 0; max-height: none; aspect-ratio: 16 / 7.2; }
.banner-preview-empty { min-height: 142px; display: grid; place-content: center; gap: 5px; text-align: center; border: 1px dashed var(--line); border-radius: 17px; color: var(--muted); background: var(--surface-solid); }
.banner-preview-empty strong { color: var(--text); }
.banner-preview-empty span { font-size: 12px; }
.banner-advanced { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 12px; }
.banner-advanced summary { cursor: pointer; color: var(--muted); font-size: 12px; }
.banner-advanced label { margin-bottom: 0; }
.banner-schedule-grid { display: grid; grid-template-columns: .55fr 1fr 1fr; gap: 10px; }
.banner-enabled-toggle { margin-top: 7px; }
.banner-editor-modal .modal-actions,
.banner-delete-modal .modal-actions {
  position: static;
  z-index: 5;
  flex: 0 0 auto;
  margin: 18px -23px -23px;
  padding: 12px 23px 14px;
  border-top: 1px solid var(--line);
  background: linear-gradient(180deg, color-mix(in srgb, var(--surface-solid) 86%, transparent), var(--surface-solid) 34%);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.banner-delete-modal { width: min(500px, 100%); }
.banner-delete-content {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  display: grid;
  gap: 14px;
  padding-right: 2px;
}
.banner-delete-summary { display: grid; grid-template-columns: 104px minmax(0, 1fr); align-items: center; gap: 12px; padding: 10px; border: 1px solid var(--line); border-radius: 15px; background: var(--bg-soft); }
.banner-delete-thumb { width: 104px; aspect-ratio: 16 / 9; overflow: hidden; border-radius: 11px; background: var(--surface-solid); }
.banner-delete-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.banner-delete-placeholder { width: 100%; height: 100%; display: grid; place-items: center; color: var(--muted); }
.banner-delete-summary > div:last-child { min-width: 0; display: grid; gap: 5px; }
.banner-delete-summary strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.banner-delete-summary small { color: var(--muted); font-size: 11px; }
.banner-confirm-phrase { display: grid; gap: 7px; }
.banner-confirm-phrase span { color: var(--muted); font-size: 12px; }
.banner-confirm-phrase code { width: 100%; overflow-wrap: anywhere; border: 1px solid color-mix(in srgb, var(--danger) 28%, var(--line)); border-radius: 12px; background: color-mix(in srgb, var(--danger) 7%, var(--bg-soft)); color: var(--text); padding: 11px 12px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.banner-delete-input { margin: 0 !important; scroll-margin-bottom: 120px; }
.banner-delete-input .input { font-size: 16px; }

@media (max-width: 760px) {
  .banner-stage { margin-left: -1px; margin-right: -1px; margin-bottom: 24px; border-radius: 19px; }
  .banner-track { border-radius: 0; }
  .banner-card { aspect-ratio: 16 / 7.55; min-height: 0; max-height: none; border-radius: 19px; }
  .banner-overlay { padding: 48px 17px 16px; gap: 12px; }
  .banner-copy { max-width: 78%; }
  .banner-copy strong { font-size: clamp(19px, 5.5vw, 25px); }
  .banner-copy span { margin-top: 5px; font-size: 12px; }
  .banner-badge { top: 11px; left: 11px; min-height: 22px; padding: 3px 8px; font-size: 9px; }
  .banner-dots { top: 10px; right: 10px; padding: 5px 7px; }
  .banner-cta { width: 35px; height: 35px; flex-basis: 35px; font-size: 16px; }
  .banner-pure-cta { right: 12px; bottom: 12px; }
  .banner-admin-grid { gap: 13px; }
  .banner-admin-card { padding: 13px; }
  .banner-mode-switch { grid-template-columns: 1fr; }
  .banner-copy-fields { grid-template-columns: 1fr; }
  .banner-schedule-grid { grid-template-columns: 1fr; }
  .banner-editor-section { padding: 14px; }
  .banner-editor-modal .modal-actions,
  .banner-delete-modal .modal-actions {
    margin-left: -23px;
    margin-right: -23px;
    margin-bottom: calc(-22px - var(--safe-bottom));
    padding-bottom: calc(13px + var(--safe-bottom));
  }
  .banner-delete-summary { grid-template-columns: 86px minmax(0,1fr); }
  .banner-delete-thumb { width: 86px; }
  html.ios-telegram .banner-editor-modal .modal-actions,
  html.ios-telegram .banner-delete-modal .modal-actions {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: var(--surface-solid);
  }
  html.ios-telegram .banner-editor-modal-backdrop,
  html.ios-telegram .banner-delete-modal-backdrop {
    top: var(--ios-visual-offset-top, 0px) !important;
    bottom: auto !important;
    height: var(--ios-visual-height, var(--viewport-height)) !important;
    min-height: 0 !important;
  }
  html.ios-telegram .banner-editor-modal,
  html.ios-telegram .banner-delete-modal {
    max-height: calc(var(--ios-visual-height, var(--viewport-height)) - 8px) !important;
  }
}
