:root {
  --bg: #f6f1ea; --surface: #fffdf9; --surface-2: #efe8de; --line: #e0d6c8;
  --text: #2a231c; --muted: #7a6d5f;
  --heat: #c4562f; --heat-soft: #f6dccf;
  --light: #c98a0b; --light-soft: #f7e7bd;
  --cool: #1f7a8c; --cool-soft: #cfe8ec;
  --accent: #c4562f; --ok: #3f7d4f; --danger: #b3261e;
  --radius: 18px; --shadow: 0 1px 2px rgba(60,40,20,.06), 0 8px 24px rgba(60,40,20,.06);
  --display: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --ui: ui-rounded, "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #17130f; --surface: #221c16; --surface-2: #2c251d; --line: #3a3128;
  --text: #f1e8dc; --muted: #a39482;
  --heat: #ee8a5f; --heat-soft: #4a2a1d;
  --light: #f0b63a; --light-soft: #473714;
  --cool: #5cc0d3; --cool-soft: #1b3d45;
  --accent: #ee8a5f; --ok: #7bc08c; --danger: #f2827a;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.5 var(--ui); min-height: 100vh; }
h1, h2, h3 { font-family: var(--display); font-weight: 600; letter-spacing: -.01em; margin: 0; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.sr-only, input.sr-only, input[type=file].sr-only { position: absolute; width: 1px; min-width: 0; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }

/* buttons & fields */
.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 9px 16px; min-height: 44px; font-weight: 600; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
:root[data-theme="dark"] .btn.primary { color: #1a120c; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--danger); }
.btn.small { min-height: 36px; padding: 5px 12px; font-size: .9rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-weight: 600; font-size: .9rem; }
input[type=text], input[type=password], select, textarea:not(.code) {
  width: 100%; min-height: 44px; padding: 8px 12px; font: inherit; border-radius: 12px; border: 1px solid var(--line); background: var(--bg);
}
.error { color: var(--danger); font-weight: 600; min-height: 1.5em; margin: 0 0 8px; }
.notice { background: var(--light-soft); border-radius: 12px; padding: 10px 14px; margin-bottom: 16px; }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.topbar-inner { max-width: 1100px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 14px; }
.brand { font-family: var(--display); font-size: 1.35rem; font-weight: 700; display: flex; align-items: center; gap: 8px; text-decoration: none; color: inherit; }
.brand svg { width: 28px; height: 28px; }
.nav { display: flex; gap: 4px; margin-left: auto; }
.nav a { padding: 8px 14px; border-radius: 999px; text-decoration: none; color: var(--muted); font-weight: 600; min-height: 40px; display: inline-flex; align-items: center; }
.nav a[aria-current="page"] { background: var(--surface-2); color: var(--text); }
.icon-btn { border: 1px solid var(--line); background: var(--surface); width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; }
.icon-btn svg { width: 20px; height: 20px; }
main { max-width: 1100px; margin: 0 auto; padding: 22px 16px 80px; }

/* rooms & tiles */
.room { margin-bottom: 34px; }
.room-head { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; }
.room-head h2 { font-size: 1.7rem; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { background: var(--surface-2); border-radius: 999px; padding: 3px 12px; font-weight: 600; font-size: .92rem; font-variant-numeric: tabular-nums; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.grid + .panel { margin-top: 22px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); display: grid; gap: 12px; align-content: start; position: relative; }
.tile.off { opacity: .86; }
.tile.unavailable { opacity: .5; }
.tile-top { display: flex; align-items: center; gap: 12px; }
.tile-ico { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none; background: var(--surface-2); }
.tile-ico svg { width: 22px; height: 22px; }
.tile.light.on .tile-ico { background: var(--light-soft); color: var(--light); }
.tile.heater.on .tile-ico { background: var(--heat-soft); color: var(--heat); }
.tile.ac.on .tile-ico { background: var(--cool-soft); color: var(--cool); }
.tile-name { font-weight: 650; line-height: 1.2; }
.tile-sub { font-size: .85rem; color: var(--muted); }
.switch { margin-left: auto; width: 54px; height: 32px; border-radius: 999px; border: 0; background: var(--line); position: relative; flex: none; transition: background .2s; }
.switch::after { content: ""; position: absolute; top: 4px; left: 4px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .2s; }
.switch[aria-checked="true"] { background: var(--ok); }
.tile.light .switch[aria-checked="true"] { background: var(--light); }
.tile.heater .switch[aria-checked="true"] { background: var(--heat); }
.tile.ac .switch[aria-checked="true"] { background: var(--cool); }
.switch[aria-checked="true"]::after { transform: translateX(22px); }
.switch:disabled { opacity: .5; cursor: not-allowed; }
input[type=range] { width: 100%; accent-color: var(--light); height: 28px; }
.stepper { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.stepper .big { font-family: var(--display); font-size: 2.1rem; font-variant-numeric: tabular-nums; line-height: 1; text-align: center; }
.stepper .big small { font-size: 1rem; color: var(--muted); }
.stepper .btn { width: 48px; padding: 0; font-size: 1.4rem; }
.reading { font-family: var(--display); font-size: 2.3rem; line-height: 1; font-variant-numeric: tabular-nums; }
.reading small { font-size: 1rem; color: var(--muted); }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); border: 2px dashed var(--line); border-radius: var(--radius); }

/* panels */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 22px; box-shadow: var(--shadow); }
.panel h3 { font-size: 1.3rem; margin-bottom: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 8px 0; border-top: 1px solid var(--line); }
.row:first-of-type { border-top: 0; }
.row .grow { flex: 1 1 160px; min-width: 120px; }
.row select { width: auto; min-width: 120px; flex: 0 1 170px; }
.tag { font-size: .75rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--heat-soft); color: var(--heat); }
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs button { border: 1px solid var(--line); background: var(--surface); padding: 6px 14px; min-height: 40px; border-radius: 999px; font-weight: 600; }
.tabs button[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.chart { width: 100%; height: 260px; display: block; }
.chart .axis { stroke: var(--line); }
.chart text { fill: var(--muted); font-size: 11px; font-family: var(--ui); }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2.4; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: var(--accent); opacity: .12; }

/* landing */
.landing { min-height: 100vh; display: grid; grid-template-columns: 1.1fr .9fr; }
.hero { padding: 48px clamp(20px, 6vw, 80px); display: flex; flex-direction: column; justify-content: center; gap: 22px;
  background: radial-gradient(900px 500px at 10% 0%, var(--heat-soft), transparent 60%), radial-gradient(700px 400px at 100% 100%, var(--cool-soft), transparent 60%), var(--bg); }
.hero h1 { font-size: clamp(2.4rem, 5vw, 4rem); line-height: 1.05; }
.hero p { font-size: 1.15rem; max-width: 34ch; color: var(--muted); margin: 0; }
.feat { display: flex; gap: 10px; flex-wrap: wrap; }
.feat span { display: inline-flex; gap: 8px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; font-weight: 600; }
.feat svg { width: 18px; height: 18px; }
.login-side { display: grid; place-items: center; padding: 32px 20px; background: var(--surface); border-left: 1px solid var(--line); position: relative; }
.login-card { width: min(380px, 100%); }
.login-card h2 { font-size: 1.8rem; margin-bottom: 18px; }
.theme-float { position: absolute; top: 16px; right: 16px; display: flex; gap: 8px; align-items: center; }
@media (max-width: 800px) { .landing { grid-template-columns: 1fr; } .hero { padding-top: 56px; padding-bottom: 28px; } .login-side { border-left: 0; border-top: 1px solid var(--line); } }
@media (max-width: 560px) { .topbar-inner { gap: 8px; } .nav { gap: 0; } .nav a { padding: 8px 9px; font-size: .88rem; } .brand span, .signout-top { display: none; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

.page-title { margin-bottom: 14px; }
.flat { margin: 0; }
.btn.block { width: 100%; display: flex; justify-content: center; align-items: center; }
.btn.link { text-decoration: none; }
.toast { position: fixed; left: 16px; right: 16px; bottom: 16px; max-width: 520px; margin: auto; z-index: 20; box-shadow: var(--shadow); }
[hidden] { display: none !important; }

/* ===== portal shell ===== */
.shell { display: grid; grid-template-columns: 280px 1fr; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--surface); border-right: 1px solid var(--line);
  padding: 16px 12px; display: flex; flex-direction: column; gap: 14px; }
.sidebar.locked .side-nav, .sidebar.locked .side-bottom a { pointer-events: none; opacity: .4; }
.content { min-width: 0; }
.content main { max-width: 1100px; margin: 0 auto; padding: 28px clamp(16px, 3vw, 36px) 80px; outline: none; }
.mobilebar { display: none; }
.scrim { display: none; }

.profile-card { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 16px; background: var(--surface-2); text-decoration: none; color: inherit; border: 1px solid transparent; }
.profile-card:hover, .profile-card[aria-current="page"] { border-color: var(--accent); }
.avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 700; font-family: var(--display); font-size: 1.1rem; flex: none; }
:root[data-theme="dark"] .avatar { color: #1a120c; }
.profile-text { display: grid; line-height: 1.25; min-width: 0; }
.profile-text strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-text small { color: var(--muted); }

.side-nav { display: grid; gap: 2px; align-content: start; }
.side-title { font-size: .75rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 16px 12px 6px; }
.side-link { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; text-decoration: none; color: var(--text); font-weight: 600; min-height: 44px; }
.side-link svg { width: 20px; height: 20px; flex: none; color: var(--muted); }
.side-link:hover { background: var(--surface-2); }
.side-link[aria-current="page"] { background: var(--heat-soft); color: var(--heat); }
.side-link[aria-current="page"] svg { color: inherit; }
.side-empty { padding: 0 12px; font-size: .9rem; }
.side-bottom { margin-top: auto; display: grid; gap: 8px; border-top: 1px solid var(--line); padding-top: 12px; }
.side-tools { display: flex; gap: 8px; }
.grow-btn { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; }
.grow-btn svg { width: 18px; height: 18px; }

.page-head { margin-bottom: 22px; }
.page-head h1 { font-size: clamp(1.7rem, 3vw, 2.3rem); }
.page-head p { margin: 4px 0 0; }
.app-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.app-card { display: flex; align-items: center; gap: 16px; padding: 20px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); text-decoration: none; color: inherit; transition: transform .15s, border-color .15s; }
.app-card:hover { transform: translateY(-2px); border-color: var(--accent); }
.app-ico { width: 52px; height: 52px; border-radius: 16px; background: var(--heat-soft); color: var(--heat); display: grid; place-items: center; flex: none; }
.app-ico svg { width: 26px; height: 26px; }
.app-text { display: grid; line-height: 1.3; min-width: 0; }
.app-text small { color: var(--muted); }
.app-ext { margin-left: auto; color: var(--muted); }
.app-ext svg { width: 18px; height: 18px; }
.cols { display: grid; gap: 22px; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); align-items: start; }
.cols > .panel, .cols > div > .panel { margin-bottom: 22px; }
.panel.highlight { border-color: var(--accent); max-width: 520px; }

.tablink { padding: 6px 16px; min-height: 40px; display: inline-flex; align-items: center; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; text-decoration: none; color: var(--text); }
.tablink[aria-current="page"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.user-card { border-top: 1px solid var(--line); padding: 14px 0; display: grid; gap: 10px; }
.user-card:first-of-type { border-top: 0; }
.user-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.user-head .tile-ico { width: 34px; height: 34px; }
.user-head .tile-ico svg { width: 18px; height: 18px; }
.form-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.row.tight { border-top: 0; padding: 0; }
.tag.off { background: var(--surface-2); color: var(--muted); }
.tag.ok { background: var(--cool-soft); color: var(--cool); }
.tile-opt { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; font-weight: 600; }
.tile-opt select { max-width: 55%; }
.notice.alert { border-color: var(--danger); color: var(--danger); font-weight: 600; }
.chart-stats { margin: 4px 0 0; font-size: .85rem; }
.section-sep { border: 0; border-top: 2px solid var(--line); margin: 34px 0 22px; }
.scene-schedule + .scene-schedule, .scene-schedule + div > .scene-schedule, .scene-schedules > div > .scene-schedule + .scene-schedule { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 14px; }
.scene-schedule { padding-bottom: 2px; }
.integ-tags { display: flex; gap: 6px; }
.tag-slot { display: inline-flex; justify-content: center; min-width: 38px; }
.scene-manage > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 10px; padding: 8px 0; font-weight: 700; }
.scene-manage > summary::-webkit-details-marker { display: none; }
.scene-manage > summary::before { content: "▸"; display: inline-block; transition: transform .15s; }
.scene-manage[open] > summary::before { transform: rotate(90deg); }
.scene-manage-title { font-family: var(--serif, inherit); font-size: 1.5rem; }
.scene-manager { margin-top: 12px; }
.scene-tile { cursor: pointer; text-align: left; color: inherit; font: inherit; width: 100%; }
.scene-tile:hover:not(:disabled) { border-color: var(--accent); }
.scene-tile:disabled { opacity: .6; cursor: progress; }
.scene-item { border-top: 1px solid var(--line); padding: 10px 0; }
.scene-item:first-of-type { border-top: 0; }
.scene-editor { display: grid; gap: 8px; padding: 10px 0 4px 8px; }
.scene-section { margin-top: 14px; }
.scene-section h4 { margin: 0; font-size: 1rem; }
.scene-row { display: grid; grid-template-columns: minmax(110px, 190px) minmax(0, 1fr) auto; align-items: center; gap: 10px; }
@media (max-width: 800px) { .scene-row { grid-template-columns: 1fr; } }
.scene-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.scene-color { width: 56px; margin: 0; }
.sensor-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: stretch; }
.room-move { display: inline-flex; gap: 4px; margin-left: auto; }
.sensor-row-bar { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; }
.sensor-row-bar strong { flex: 1; }
.sensor-gap { min-height: 0; }          /* an empty cell keeps the temperature / humidity columns aligned */
.sensor-card { margin-bottom: 0; display: flex; flex-direction: column; }
.sensor-card .room-head { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 8px; }
.sensor-card .room-head h3 { overflow-wrap: anywhere; }
.sensor-card .tag, .sensor-card .chip { white-space: nowrap; }
.sensor-card .chart-box { margin-top: auto; }
.btn.star[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
.sensor-issue { margin: 0 0 8px; font-weight: 600; }
.sensor-card.unavailable .chart { opacity: .45; }
.sensor-card .chart { height: 170px; }
.sensor-card.temperature .chart .line { stroke: var(--heat); }
.sensor-card.temperature .chart .area { fill: var(--heat); }
.sensor-card.humidity .chart .line { stroke: var(--cool); }
.sensor-card.humidity .chart .area { fill: var(--cool); }
@media (max-width: 800px) { .sensor-cols { grid-template-columns: 1fr; } .sensor-gap { display: none; } }
.color-row { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.color-row .color-pick { width: 56px; height: 34px; margin: 0; flex: none; }
.color-preset { width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--line); cursor: pointer; padding: 0; flex: none; }
.color-preset:hover:not(:disabled), .color-preset[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.color-preset:disabled { opacity: .5; cursor: default; }
.color-pick { width: 100%; height: 36px; padding: 2px; margin: 8px 0 0; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); cursor: pointer; }
.color-pick:disabled { opacity: .5; cursor: default; }
.integ-layout { display: grid; grid-template-columns: minmax(200px, 250px) minmax(0, 1fr); gap: 22px; align-items: start; }
.integ-list { display: grid; gap: 6px; position: sticky; top: 16px; }
.integ-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 44px; padding: 6px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: inherit; font: inherit; font-weight: 600; text-align: left; cursor: pointer; }
.integ-item:hover, .integ-item[aria-current="true"] { border-color: var(--accent); }
.integ-group { font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; margin: 6px 4px 0; }
.integ-item .tag { margin: 0; flex: none; }
@media (max-width: 800px) { .integ-layout { grid-template-columns: 1fr; } .integ-list { position: static; } }
.check { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; min-height: 36px; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
input:disabled { opacity: .6; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(310px, 86vw); z-index: 30; transform: translateX(-102%); transition: transform .22s; box-shadow: var(--shadow); }
  .shell.open .sidebar { transform: none; }
  .shell.open .scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 20; }
  .mobilebar { display: flex; align-items: center; gap: 12px; padding: 10px 16px; position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
  .mobilebar .brand span { display: inline; }
}

/* ===== bookmarks ===== */
.bm-search { margin-bottom: 14px; max-width: 520px; }
.bm-colbar { margin-bottom: 14px; display: grid; gap: 10px; }
.bm-coltabs { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.bm-coltab { border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 999px; padding: 6px 16px; font: inherit; font-weight: 600; min-height: 36px; cursor: pointer; }
.bm-coltab small { margin-left: 8px; color: var(--muted); font-weight: 400; }
.bm-coltab:hover { border-color: var(--accent); }
.bm-coltab[aria-pressed="true"] { background: var(--heat-soft); border-color: var(--accent); color: var(--heat); }
.bm-colform { max-width: 620px; align-items: center; }
.bm-layout { display: grid; grid-template-columns: 250px 1fr; gap: 20px; align-items: start; }
.bm-tree { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; position: sticky; top: 16px; max-height: calc(100vh - 40px); overflow: auto; }
.bm-sub { margin-left: 14px; }
.bm-folder { width: 100%; display: flex; align-items: center; gap: 8px; border: 0; background: none; padding: 7px 8px; border-radius: 10px; text-align: left; min-height: 38px; }
.bm-folder svg { width: 18px; height: 18px; color: var(--muted); flex: none; }
.bm-folder span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bm-folder small { color: var(--muted); }
.bm-folder:hover { background: var(--surface-2); }
.bm-folder[aria-current="true"] { background: var(--heat-soft); color: var(--heat); font-weight: 650; }
.bm-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.bm-list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.bm-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 8px 12px; border-top: 1px solid var(--line); }
.bm-row:first-child { border-top: 0; }
.bm-open { flex: 1 1 13em; min-width: 0; display: flex; align-items: center; gap: 12px; border: 0; background: none; text-align: left; padding: 4px 0; }
.bm-open.static { cursor: default; }
.bm-text { display: grid; min-width: 0; line-height: 1.3; }
.bm-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
a.bm-title { text-decoration: none; }
a.bm-title:hover { text-decoration: underline; color: var(--accent); }
.bm-text small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bm-letter { width: 34px; height: 34px; border-radius: 10px; background: var(--cool-soft); color: var(--cool); display: grid; place-items: center; font-weight: 700; flex: none; }
.bm-letter.big { width: 48px; height: 48px; font-size: 1.3rem; border-radius: 14px; }
.bm-actions { display: flex; gap: 6px; flex: none; margin-left: auto; }
.bm-form { margin-bottom: 14px; }
.browser-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.browser-card { display: grid; gap: 6px; justify-items: center; padding: 16px 10px; border: 2px solid var(--line); border-radius: var(--radius); background: var(--surface); min-height: 44px; }
.browser-card[aria-pressed="true"] { border-color: var(--accent); background: var(--heat-soft); }
.steps { padding-left: 20px; display: grid; gap: 10px; }
textarea.code { width: 100%; font: 13px/1.4 ui-monospace, monospace; padding: 10px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--text); }
input[type=file] { width: 100%; }
.bm-sep { border: 0; border-top: 1px solid var(--line); margin: 8px 0; }
.bm-tail { margin-top: 10px; padding: 10px; border: 2px dashed transparent; border-radius: var(--radius); text-align: center; color: transparent; font-size: .85rem; transition: color .15s; }
body:has(.dragging) .bm-tail { color: var(--muted); border-color: var(--line); }
.dragging { opacity: .45; }
.bm-row[draggable="true"] { cursor: grab; }
.drop-before { box-shadow: inset 0 3px 0 var(--accent); }
.drop-into { background: var(--heat-soft); outline: 2px solid var(--accent); outline-offset: -2px; }
.tag-bar { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.tag-chip { border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 999px; padding: 3px 10px; font: inherit; font-size: .8rem; min-height: 28px; cursor: pointer; }
.tag-chip small { margin-left: 6px; color: var(--muted); }
.tag-chip:hover { border-color: var(--accent); color: var(--accent); }
.tag-chip.small { padding: 0 8px; min-height: 22px; font-size: .72rem; }
.bm-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }
.tag.bad { margin-left: 0; background: var(--danger); color: var(--surface); }
.bm-row.broken .bm-title { text-decoration: line-through; text-decoration-color: var(--danger); }
.bm-pin { color: var(--accent); }
.bm-pin a { color: var(--text); }
.icon-btn[aria-expanded="true"] { background: var(--heat-soft); color: var(--accent); }
.icon-btn { min-width: 34px; padding-inline: 8px; }
.icon-btn[aria-pressed="true"] { color: var(--accent); }
.bm-quick { margin-bottom: 18px; }
.dup { margin-bottom: 10px; }
.check-row { display: flex; align-items: center; gap: 8px; margin-top: 12px; cursor: pointer; }
.check-row input { width: 20px; height: 20px; flex: none; }
.pv-list { max-height: 180px; overflow: auto; margin: 4px 0 8px; padding-left: 20px; }
@media (max-width: 860px) { .bm-layout { grid-template-columns: 1fr; } .bm-tree { position: static; max-height: 220px; } .bm-row { flex-wrap: wrap; } }
.pick-list { display: grid; gap: 2px; margin-bottom: 12px; }
.pick-row { display: flex; gap: 10px; align-items: center; padding: 8px 4px; border-top: 1px solid var(--line); min-height: 44px; cursor: pointer; }
.pick-row input { width: 20px; height: 20px; flex: none; }
.pick-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag { margin-left: 8px; padding: 2px 8px; border-radius: 999px; background: var(--cool-soft); color: var(--cool); font-size: .75rem; font-weight: 700; }
.ok-line { color: var(--cool); font-weight: 600; }
.linklike { background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; font: inherit; cursor: pointer; }
.spinner { display: inline-block; width: 12px; height: 12px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; vertical-align: -1px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }
.bm-letter { position: relative; overflow: hidden; }
.bm-letter img { position: absolute; inset: 0; margin: auto; width: 20px; height: 20px; object-fit: contain; opacity: 0; }
.bm-letter.has-img { background: var(--surface); border: 1px solid var(--line); color: transparent; }
.bm-letter.has-img img { opacity: 1; }
.icon-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 6px; margin-bottom: 12px; }
.ico-opt { display: grid; place-items: center; min-height: 44px; border: 2px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--text); padding: 0; }
.ico-opt svg { width: 22px; height: 22px; }
.ico-opt[aria-pressed="true"] { border-color: var(--accent); background: var(--heat-soft); color: var(--accent); }

/* ===== colour palettes (terracotta is the default, defined above) ===== */
:root[data-palette="ocean"] { --bg: #eef4f7; --surface: #fbfdfe; --surface-2: #e0ebf0; --line: #cfdde4; --text: #16262e; --muted: #5d7480; --heat: #1f6f9a; --heat-soft: #cfe6f2; --accent: #1f6f9a; }
:root[data-palette="ocean"][data-theme="dark"] { --bg: #0e171c; --surface: #16232a; --surface-2: #1e2e37; --line: #2a3d48; --text: #e6f0f5; --muted: #93a9b5; --heat: #5cb6e3; --heat-soft: #16384a; --accent: #5cb6e3; }
:root[data-palette="forest"] { --bg: #f0f3ec; --surface: #fbfcf8; --surface-2: #e3e9db; --line: #d2dbc7; --text: #1d2a1f; --muted: #667563; --heat: #3c7a4a; --heat-soft: #d4e8d3; --accent: #3c7a4a; }
:root[data-palette="forest"][data-theme="dark"] { --bg: #111812; --surface: #19231b; --surface-2: #223026; --line: #2f4033; --text: #e6f0e4; --muted: #97ab95; --heat: #7cc58c; --heat-soft: #1d3d25; --accent: #7cc58c; }
:root[data-palette="violet"] { --bg: #f3f0f8; --surface: #fdfcff; --surface-2: #e8e2f1; --line: #d8cfe6; --text: #251d33; --muted: #75698a; --heat: #7249c4; --heat-soft: #e0d5f5; --accent: #7249c4; }
:root[data-palette="violet"][data-theme="dark"] { --bg: #15111d; --surface: #1e1829; --surface-2: #282137; --line: #382f4b; --text: #ece6f5; --muted: #a498ba; --heat: #a98bf0; --heat-soft: #33274f; --accent: #a98bf0; }
:root[data-palette="rose"] { --bg: #f9eff1; --surface: #fffcfc; --surface-2: #f2e0e4; --line: #e8cfd5; --text: #33202a; --muted: #8a6572; --heat: #c23b6a; --heat-soft: #f8d5e0; --accent: #c23b6a; }
:root[data-palette="rose"][data-theme="dark"] { --bg: #1b1015; --surface: #271920; --surface-2: #33212a; --line: #47303b; --text: #f6e6ec; --muted: #b89aa6; --heat: #f07aa3; --heat-soft: #4d2335; --accent: #f07aa3; }
:root[data-palette="graphite"] { --bg: #f1f2f3; --surface: #fcfcfd; --surface-2: #e4e6e8; --line: #d3d6da; --text: #1f2326; --muted: #686f76; --heat: #4b5b6b; --heat-soft: #dbe1e7; --accent: #4b5b6b; }
:root[data-palette="graphite"][data-theme="dark"] { --bg: #111315; --surface: #1a1d20; --surface-2: #23272b; --line: #33383d; --text: #e9ecee; --muted: #9aa2a9; --heat: #9db4cb; --heat-soft: #27323d; --accent: #9db4cb; }
:root[data-palette="sunset"] { --bg: #fbf0e8; --surface: #fffcf9; --surface-2: #f5e1d3; --line: #ecd0bd; --text: #352019; --muted: #8c6a5b; --heat: #d9482b; --heat-soft: #fbd8c9; --accent: #d9482b; }
:root[data-palette="sunset"][data-theme="dark"] { --bg: #1c110d; --surface: #291a14; --surface-2: #35231b; --line: #4a3226; --text: #f8e8df; --muted: #bba091; --heat: #ff8a5c; --heat-soft: #55281b; --accent: #ff8a5c; }

/* swatches in the profile */
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.sw { width: 44px; height: 44px; border-radius: 50%; border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--line); background: var(--c); padding: 0; }
.sw[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--text); }
.sw[data-p="terracotta"] { --c: #c4562f; } .sw[data-p="ocean"] { --c: #1f6f9a; } .sw[data-p="forest"] { --c: #3c7a4a; }
.sw[data-p="violet"] { --c: #7249c4; } .sw[data-p="rose"] { --c: #c23b6a; } .sw[data-p="graphite"] { --c: #4b5b6b; } .sw[data-p="sunset"] { --c: #d9482b; }

/* menu position pictograms */
.layouts { display: flex; flex-wrap: wrap; gap: 10px; }
.lay-btn { display: grid; justify-items: center; gap: 6px; padding: 8px 10px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; font-size: .9rem; }
.lay-btn[aria-pressed="true"] { border-color: var(--accent); background: var(--heat-soft); color: var(--heat); }
.lay-pic { display: flex; width: 48px; height: 32px; border: 2px solid currentColor; border-radius: 7px; overflow: hidden; }
.lay-pic i { background: currentColor; opacity: .45; flex: none; }
.lay-pic b { flex: 1; }
.lay-left i, .lay-right i { width: 12px; } .lay-top i, .lay-bottom i { height: 8px; }
.lay-right { flex-direction: row-reverse; } .lay-top { flex-direction: column; } .lay-bottom { flex-direction: column-reverse; }

/* wallpapers */
.walls { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 10px; }
.wall { position: relative; width: 100%; padding: 0; border: 3px solid var(--surface); border-radius: 14px; overflow: hidden; aspect-ratio: 16 / 10; background: var(--surface-2); box-shadow: 0 0 0 1px var(--line); }
.wall img { width: 100%; height: 100%; object-fit: cover; display: block; }
.wall[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--text); }
.wall.none { display: grid; place-items: center; font-weight: 600; color: var(--muted); }
.wall-del { position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff; font-size: 16px; line-height: 1; display: grid; place-items: center; }
.wall-wrap { position: relative; }
.range { width: 100%; accent-color: var(--accent); }

/* wallpaper behind the portal */
html { background: var(--bg); }
html[data-wall] body.portal { background: transparent; }
html[data-wall] body.portal::before { content: ""; position: fixed; inset: 0; z-index: -2; background: var(--wall) center / cover no-repeat; }
html[data-wall] body.portal::after { content: ""; position: fixed; inset: 0; z-index: -1; background: color-mix(in srgb, var(--bg) calc(var(--veil, 55) * 1%), transparent); pointer-events: none; }
html[data-wall] .sidebar { background: color-mix(in srgb, var(--surface) 78%, transparent); backdrop-filter: blur(14px); }
html[data-wall] .panel, html[data-wall] .app-card, html[data-wall] .bm-tree { background: color-mix(in srgb, var(--surface) 84%, transparent); backdrop-filter: blur(10px); }
html[data-wall] .mobilebar { background: color-mix(in srgb, var(--bg) 70%, transparent); }

/* ===== menu position (wide screens; phones always use the drawer) ===== */
@media (min-width: 861px) {
  html[data-layout="right"] .shell { grid-template-columns: 1fr 280px; }
  html[data-layout="right"] .sidebar { grid-column: 2; grid-row: 1; border-right: 0; border-left: 1px solid var(--line); }
  html[data-layout="right"] .content { grid-column: 1; grid-row: 1; }

  html[data-layout="top"] .shell, html[data-layout="bottom"] .shell { grid-template-columns: 1fr; }
  html[data-layout="top"] .shell { grid-template-rows: auto 1fr; }
  html[data-layout="bottom"] .shell { grid-template-rows: 1fr auto; }
  html[data-layout="top"] .sidebar, html[data-layout="bottom"] .sidebar { height: auto; flex-direction: row; align-items: center; flex-wrap: wrap; gap: 8px 14px; padding: 8px 16px; overflow: visible; z-index: 15; }
  html[data-layout="top"] .sidebar { grid-row: 1; top: 0; border-right: 0; border-bottom: 1px solid var(--line); }
  html[data-layout="top"] .content { grid-row: 2; }
  html[data-layout="bottom"] .sidebar { grid-row: 2; top: auto; bottom: 0; border-right: 0; border-top: 1px solid var(--line); }
  html[data-layout="bottom"] .content { grid-row: 1; }
  html[data-layout="top"] .side-nav, html[data-layout="bottom"] .side-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
  html[data-layout="top"] .side-title, html[data-layout="bottom"] .side-title, html[data-layout="top"] .profile-text small, html[data-layout="bottom"] .profile-text small { display: none; }
  html[data-layout="top"] .profile-card, html[data-layout="bottom"] .profile-card { padding: 6px 12px 6px 6px; }
  html[data-layout="top"] .avatar, html[data-layout="bottom"] .avatar { width: 34px; height: 34px; font-size: .95rem; }
  html[data-layout="top"] .side-bottom, html[data-layout="bottom"] .side-bottom { margin: 0 0 0 auto; border: 0; padding: 0; display: flex; align-items: center; gap: 8px; }
  html[data-layout="top"] .bm-tree { top: 84px; max-height: calc(100vh - 104px); }
  html[data-layout="bottom"] .bm-tree { max-height: calc(100vh - 120px); }
}
#already .btn.block + .btn.block { margin-top: 10px; }

/* Logo plate above the home page and above every application: the logo has a light background, so it sits on a light
   plate in every theme. One height for all, so the plate is as tall on an application as on the home page. */
.domo-brand { --brand-h: 57px; display: flex; justify-content: center; margin: 0 0 18px; padding: 8px 16px; border-radius: var(--radius); background: #fdfdfb; border: 1px solid var(--line); box-shadow: var(--shadow); }
.domo-brand img { display: block; height: var(--brand-h); width: auto; max-width: 100%; object-fit: contain; }
/* application banners: a bigger logo in the same plate height as the home page (75 px: 2 + 69 + 2 + 2 border = 8 + 57 + 8 + 2) */
.domo-brand:not(.home-brand) { --brand-h: 69px; padding-block: 2px; }

/* logo */
.brand-img { height: 34px; width: auto; display: block; }
.hero .brand-img { height: 64px; }
html[data-theme="dark"] .brand-img { background: #fcfcfa; border-radius: 12px; padding: 4px 12px; }
.side-logo { display: block; padding: 2px 6px; flex: none; }
.side-logo .brand-img { height: 30px; }
.app-access { border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; margin: 0; }
.app-access legend { font-weight: 600; font-size: .9rem; padding: 0 6px; }
.small-note { font-size: .85rem; margin: 6px 0 0; }
.tabs.sub { margin-top: -4px; }
.tabs.sub .tablink { min-height: 34px; padding: 3px 14px; font-size: .92rem; }
.avatar.has-img { background: var(--surface-2); overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar.big { width: 72px; height: 72px; font-size: 1.6rem; }
.photo-row { gap: 12px; }

/* coloured application logos */
.app-ico { background: color-mix(in srgb, var(--ac, var(--heat)) 16%, var(--surface)); color: var(--ac, var(--heat)); }
.app-ico.small { width: 34px; height: 34px; border-radius: 10px; }
.app-ico.small svg { width: 18px; height: 18px; }
.tile-ico.colored { background: color-mix(in srgb, var(--ac) 16%, var(--surface)); color: var(--ac); }
.side-link.colored svg { color: var(--ac); }
.order-row { align-items: center; }
.order-row.off .grow, .order-row.off .app-ico { opacity: .5; }
.app-grid.as-list { grid-template-columns: 1fr; gap: 8px; }
.app-grid.as-list .app-card { padding: 10px 16px; }
.app-grid.as-list .app-ico { width: 40px; height: 40px; border-radius: 12px; }
.app-grid.as-list .app-text { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
input[type=color] { width: 44px; height: 36px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }

/* help */
.help summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 10px; }
.help summary::-webkit-details-marker { display: none; }
.help summary::before { content: "▸"; color: var(--muted); transition: transform .15s; }
.help[open] summary::before { transform: rotate(90deg); }
.help summary h3 { margin: 0; }
.help[open] summary { margin-bottom: 10px; }
.help ul { margin: 8px 0 0; padding-left: 22px; display: grid; gap: 6px; }
.help p { margin: 0 0 8px; }
.help-intro { margin-top: 0; }

/* folder icon styles */
.fglyph { display: inline-grid; place-items: center; flex: none; }
.fglyph[data-style="color"] svg { color: var(--ac); }
.fglyph[data-style="badge"] { width: 26px; height: 26px; border-radius: 50%; background: var(--ac); }
.fglyph[data-style="badge"] svg { color: #fff; width: 15px; height: 15px; }
.fglyph[data-style="emoji"] { font-size: 1.15rem; line-height: 1; width: 24px; height: 24px; }
.tile-ico .fglyph[data-style="badge"] { width: 32px; height: 32px; } .tile-ico .fglyph[data-style="badge"] svg { width: 18px; height: 18px; }
.tile-ico .fglyph[data-style="emoji"] { font-size: 1.5rem; width: 32px; height: 32px; }
.tile-ico:has(.fglyph[data-style="badge"]), .tile-ico:has(.fglyph[data-style="emoji"]) { background: none; }
.ico-opt .fglyph[data-style="badge"] { width: 28px; height: 28px; }
.style-opt { display: flex; align-items: center; gap: 14px; width: 100%; margin-bottom: 8px; padding: 10px 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); text-align: left; }
.style-opt strong { min-width: 70px; }
.style-opt[aria-pressed="true"] { border-color: var(--accent); background: var(--heat-soft); }
.style-sample { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.style-sample > svg, .style-sample .fglyph svg { width: 20px; height: 20px; flex: none; }
.style-sample .fglyph[data-style="badge"] svg { width: 15px; height: 15px; }
.bm-folder .fglyph { flex: none; overflow: visible; text-overflow: clip; }

/* home: cards / list switch */
.home-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.view-switch { display: flex; gap: 6px; }
.view-switch .icon-btn[aria-pressed="true"] { background: var(--heat-soft); border-color: var(--accent); color: var(--heat); }

/* profile sub-menus in the side menu, content without cards */
.sub-nav { display: grid; gap: 2px; margin: -6px 0 0 22px; padding-left: 12px; border-left: 2px solid var(--line); }
.sub-nav .side-link { min-height: 36px; padding: 5px 10px; font-size: .95rem; }
.sub-nav .side-link.sub2 { margin-left: 14px; font-size: .9rem; }
main.flat .panel, html[data-wall] main.flat .panel { background: none; border: 0; box-shadow: none; padding: 0; backdrop-filter: none; margin-bottom: 28px; }
main.flat .cols { gap: 8px 40px; }
main.flat .panel h3 { border-bottom: 1px solid var(--line); padding-bottom: 8px; }
@media (min-width: 861px) {
  html[data-layout="top"] .sub-nav, html[data-layout="bottom"] .sub-nav { display: flex; flex-wrap: wrap; margin: 0; padding: 0; border: 0; }
}

/* drag and drop */
[data-app][draggable="true"] { cursor: grab; }
[data-app].dragging { opacity: .35; }
.side-apps { display: grid; gap: 2px; }
.grip { color: var(--muted); letter-spacing: -2px; cursor: grab; user-select: none; }
.order-list { display: grid; }
.changelog h4 { margin: 12px 0 4px; font-size: 1rem; }

/* discussions with the administrators */
.msg-form { display: grid; gap: 10px; margin-top: 8px; }
.msg-form textarea, .msg-form input[type="text"] { width: 100%; font: inherit; }
.msg-form textarea { resize: vertical; }
.msg-actions { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.msg-actions .btn { display: inline-flex; align-items: center; gap: 8px; }
.msg-actions .btn svg { width: 18px; height: 18px; }
.att-pick { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.att-chips, .att-list { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.att-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; font-size: .85rem; text-decoration: none; color: var(--text); background: var(--surface); }
.att-chip svg { width: 15px; height: 15px; color: var(--muted); }
.att-chip.busy { opacity: .6; }
.att-chip .icon-btn.tiny { min-height: 0; width: 20px; height: 20px; padding: 0; border: 0; background: none; font-size: 1rem; line-height: 1; color: var(--muted); }
.att-img img { max-width: 160px; max-height: 120px; border-radius: 10px; border: 1px solid var(--line); display: block; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

/* the envelope next to the signed-in user */
.profile-row { display: flex; align-items: center; gap: 6px; }
.profile-row > .profile-card { flex: 1 1 auto; min-width: 0; }
.mail-badge[hidden] { display: none; }
.mail-badge { position: relative; display: inline-flex; align-items: center; justify-content: center; flex: none; width: 42px; height: 42px; border-radius: 12px; color: var(--ok); text-decoration: none; }
.mail-badge svg { width: 22px; height: 22px; }
.mail-badge:hover, .mail-badge[aria-current="page"] { background: var(--surface-2); }
.mail-badge.mine { color: var(--accent); }
.mail-badge.mine .mail-count { background: var(--accent); }
.mail-badge.inbox { color: var(--ok); }
.mail-badge.inbox.has { color: #e5484d; }
.mail-count:empty { display: none; }
.mail-count { position: absolute; top: 0; right: -2px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: #e5484d; color: #fff; font-size: .7rem; font-weight: 800; line-height: 18px; text-align: center; box-shadow: 0 0 0 2px var(--surface); }
#mobilebar .mail-badge, .mobilebar .mail-badge { margin-left: auto; }

/* discussion list */
.msg-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.msg-filters { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.msg-filters input[type="search"] { flex: 1 1 200px; min-width: 140px; }
.thread-list { display: grid; gap: 8px; }
.thread-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; text-decoration: none; color: var(--text); }
.thread-row:hover { background: var(--surface-2); }
.thread-row.unread { border-color: #e5484d; background: color-mix(in srgb, #e5484d 6%, transparent); }
.thread-row .dot { width: 9px; height: 9px; border-radius: 50%; background: #e5484d; flex: none; }
.thread-row .dot.off { background: var(--line); }
.thread-main { flex: 1 1 auto; min-width: 0; display: grid; gap: 2px; }
.thread-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.thread-last { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex: none; }
.thread-user { font-weight: 700; font-size: .85rem; }

/* one discussion */
.back a { text-decoration: none; font-weight: 600; }
.bubbles { display: grid; gap: 10px; margin: 14px 0; }
.bubble { max-width: 80%; padding: 10px 12px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface-2); }
.bubble.mine { margin-left: auto; background: var(--heat-soft); border-color: transparent; }
.bubble-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.bubble-body { white-space: pre-wrap; overflow-wrap: anywhere; margin: 6px 0 0; }
.bubble .att-list { margin-top: 8px; }
.bubble .seen { display: block; text-align: right; color: var(--muted); margin-top: 4px; }
.closed-note { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.closed-note svg { width: 18px; height: 18px; }
input.num { width: 5rem; }
.mt { margin-top: 12px; }
@media (max-width: 700px) { .bubble { max-width: 94%; } }
.msg-filters select { width: auto; flex: 0 1 210px; }
.back a { color: var(--heat); }
.dev-right { display: inline-flex; margin: 8px 0; }
.side-row { display: flex; align-items: center; gap: 4px; }
.side-row > .side-link { flex: 1 1 auto; min-width: 0; }

/* formatted text */
.rich { overflow-wrap: anywhere; }
.rich p { margin: 0 0 .6em; } .rich h3, .rich h4 { margin: .4em 0; font-size: 1.05rem; }
.rich ul, .rich ol { margin: .3em 0 .6em 1.3em; padding: 0; }
.rich blockquote { margin: .4em 0; padding: 2px 12px; border-left: 3px solid var(--line); color: var(--muted); }
.rich code, .rich pre { font-family: ui-monospace, monospace; background: var(--surface-2); border-radius: 6px; padding: 1px 5px; }
.rich a { color: var(--heat); }
.rich-editor { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--surface); }
.rich-bar { display: flex; flex-wrap: wrap; gap: 4px; padding: 6px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.rb { min-width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); font-weight: 700; cursor: pointer; }
.rb:hover { background: var(--heat-soft); }
.rb.i { font-style: italic; } .rb.u { text-decoration: underline; } .rb.s { text-decoration: line-through; }
.rb-link { display: flex; gap: 8px; padding: 6px; border-bottom: 1px solid var(--line); }
.rb-link[hidden] { display: none; }
.rb-url { flex: 1 1 auto; }
.rich-area { min-height: 140px; max-height: 420px; overflow: auto; padding: 10px 12px; outline: none; }
.rich-area:empty::before { content: attr(data-ph); color: var(--muted); }
.to-box { border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; }
.to-box legend { font-weight: 700; padding: 0 6px; }
.recipients { max-height: 180px; overflow: auto; margin-top: 8px; }
.btn svg { width: 18px; height: 18px; flex: none; }
a.btn { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; }
.desc-langs { display: grid; gap: 8px; margin: 8px 0; }
.desc-lang { display: flex; align-items: center; gap: 8px; }
.desc-lang .tag { margin: 0; flex: none; min-width: 2.2rem; text-align: center; }
.desc-lang input { flex: 1 1 auto; min-width: 0; }
.app-icons { margin-top: 8px; }
.app-pic { width: 100%; height: 100%; object-fit: contain; border-radius: inherit; display: block; }
.side-link .app-pic { width: 20px; height: 20px; flex: none; border-radius: 5px; }
.app-ico.pic, .tile-ico.pic { background: var(--surface); border: 1px solid var(--line); padding: 5px; overflow: hidden; }
.app-ico.pic .app-pic, .tile-ico.pic .app-pic { border-radius: 8px; }
.pic-row { align-items: center; }
.pic-row .tile-ico { width: 40px; height: 40px; }

.banner-row { display: flex; flex-direction: column; gap: 8px; }
.pic-row .banner-prev { width: 96px; height: 44px; }
.sub-tabs { margin: 10px 0 14px; flex-wrap: wrap; }
.log-filters { gap: 10px; margin-bottom: 6px; }
.log-filters select { flex: 0 1 auto; width: auto; max-width: 100%; }
.log-filters input { flex: 1 1 220px; min-width: 140px; }
.log-row { display: grid; grid-template-columns: 11rem 12rem 9rem 1fr 8.5rem; gap: 10px; align-items: center; font-size: .92rem; }
.log-row > * { min-width: 0; overflow-wrap: anywhere; }
.log-head { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); border-top: 0; border-bottom: 1px solid var(--line); padding-top: 0; }
@media (max-width: 820px) {
  .log-head { display: none; }
  .log-row { grid-template-columns: 1fr 1fr; }
  .log-row > [data-label]::before { content: attr(data-label) " : "; color: var(--muted); font-weight: 400; }
  .log-row > [data-label]:nth-child(2)::before { content: none; }
}
.tag.err { background: var(--danger); color: var(--surface); }
.logline { align-items: flex-start; font-size: .85rem; }
.logline pre { margin: 0; font: 12.5px/1.4 ui-monospace, monospace; white-space: pre-wrap; overflow-wrap: anywhere; flex-basis: 100%; }

/* Two-step verification */
.qr { width: 200px; height: 200px; max-width: 100%; border-radius: 8px; border: 1px solid var(--line); display: block; margin: 8px 0; }
.codes { list-style: none; padding: 0; margin: 0 0 12px; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.codes li { background: var(--surface-2); border-radius: 8px; padding: 8px 10px; text-align: center; }
.codes code { font: 600 1rem ui-monospace, monospace; letter-spacing: .04em; user-select: all; }
.stack { display: grid; gap: 6px; }
#mfa-code { letter-spacing: .12em; font-size: 1.15rem; text-align: center; }

/* ===== tablets and other touch screens ===== */
.arrange-btn { margin-left: 8px; }
.arrange-btn[aria-pressed="true"] { background: var(--heat-soft); border-color: var(--accent); color: var(--heat); }
.app-card.arranging { cursor: default; }
.app-card.arranging:hover { transform: none; border-color: var(--line); }
.app-card.arranging .app-text { flex: 1; min-width: 0; }
.order-btns { display: flex; gap: 6px; flex: none; margin-left: auto; }
.bm-move-title { margin: 0 0 8px; font-weight: 650; overflow-wrap: anywhere; }
.view-switch { align-items: center; }
@media (pointer: coarse) {
  .btn.small, .row .btn, .bm-actions .btn { min-height: 44px; padding-inline: 14px; }
  .btn.small.icon-btn, .icon-btn { min-width: 44px; min-height: 44px; }
  .check { min-height: 44px; }
  .check input { width: 22px; height: 22px; }
  .bm-folder { min-height: 44px; }
  .tag-chip { min-height: 40px; padding-inline: 14px; }
  .tag-chip.small { min-height: 32px; padding-inline: 10px; font-size: .8rem; }
  .tabs button { min-height: 44px; }
  .bm-row { padding-block: 10px; gap: 8px 10px; }
  .order-row .btn, .order-row .check { min-height: 44px; }
  .check-row input { width: 24px; height: 24px; }
  .order-row .grip { display: none; }
}

/* ===== collapsible menu (side menus on wide screens): rail of icons, opens on hover, can be pinned open ===== */
.side-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.side-toggle { display: none; flex: none; }
@media (min-width: 861px) {
  html:not([data-layout="top"]):not([data-layout="bottom"]) .side-toggle { display: grid; }
  html:not([data-layout="top"]):not([data-layout="bottom"]) .shell.rail { grid-template-columns: 72px 1fr; }
  html[data-layout="right"] .shell.rail { grid-template-columns: 1fr 72px; }
  html:not([data-layout="top"]):not([data-layout="bottom"]) .shell.rail .sidebar { width: 72px; z-index: 25; justify-self: start; transition: width .16s ease, box-shadow .16s ease; overflow-x: hidden; }
  html[data-layout="right"] .shell.rail .sidebar { justify-self: end; }
  /* hovering or tabbing into the rail opens it over the page */
  html:not([data-layout="top"]):not([data-layout="bottom"]) .shell.rail .sidebar:hover,
  html:not([data-layout="top"]):not([data-layout="bottom"]) .shell.rail .sidebar:focus-within { width: 280px; box-shadow: var(--shadow); }
  /* closed rail: icons only */
  html:not([data-layout="top"]):not([data-layout="bottom"]) .shell.rail .sidebar:not(:hover):not(:focus-within) { padding-inline: 10px; }
  .shell.rail .sidebar:not(:hover):not(:focus-within) .side-logo,
  .shell.rail .sidebar:not(:hover):not(:focus-within) .profile-text,
  .shell.rail .sidebar:not(:hover):not(:focus-within) .side-title,
  .shell.rail .sidebar:not(:hover):not(:focus-within) .side-link span,
  .shell.rail .sidebar:not(:hover):not(:focus-within) .sub-nav,
  .shell.rail .sidebar:not(:hover):not(:focus-within) .mail-badge,
  .shell.rail .sidebar:not(:hover):not(:focus-within) .lbl { display: none; }
  .shell.rail .sidebar:not(:hover):not(:focus-within) .side-head { justify-content: center; }
  .shell.rail .sidebar:not(:hover):not(:focus-within) .profile-card { justify-content: center; padding: 8px 0; }
  .shell.rail .sidebar:not(:hover):not(:focus-within) .side-link { justify-content: center; padding-inline: 0; }
  .shell.rail .sidebar:not(:hover):not(:focus-within) .side-tools { flex-direction: column; }
  .shell.rail .sidebar:not(:hover):not(:focus-within) .grow-btn { padding-inline: 0; }
}

/* separators between the groups of "My profile" (profile + appearance | applications | messaging) */
.sub-sep { border: 0; border-top: 1px solid var(--line); margin: 6px 4px; }
.tab-sep { width: 1px; align-self: stretch; background: var(--line); margin: 4px 2px; }

/* menu header: the logo is centred, the collapse button stays on the right */
.side-head { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; gap: 8px; }
.side-head .side-logo { grid-column: 2; justify-self: center; }
.side-head .side-toggle { grid-column: 3; }
@media (min-width: 861px) {
  html[data-layout="top"] .side-head, html[data-layout="bottom"] .side-head { display: flex; }
  .shell.rail .sidebar:not(:hover):not(:focus-within) .side-head { grid-template-columns: 1fr; }
  .shell.rail .sidebar:not(:hover):not(:focus-within) .side-head .side-toggle { grid-column: 1; justify-self: center; }
}

/* messaging: select several discussions to mark them read / unread */
.thread-line { display: flex; align-items: center; gap: 8px; }
.thread-line .thread-row { flex: 1 1 auto; min-width: 0; }
.thread-line .check.sel { min-height: 0; flex: none; }
.msg-bulk { margin: 0 0 8px; }
.msg-bulk .check { margin-right: 4px; }

/* small on/off switch (lists of applications) */
.switch.small { width: 42px; height: 24px; margin-left: 0; }
.switch.small::after { top: 3px; left: 3px; width: 18px; height: 18px; }
.switch.small[aria-checked="true"]::after { transform: translateX(18px); }
.integ-row { display: flex; align-items: center; gap: 8px; }
.integ-row .integ-item { flex: 1 1 auto; min-width: 0; }
.integ-item.off .integ-name { opacity: .6; }

/* certificate sign-in */
.cert-password { font: 600 1.15rem ui-monospace, monospace; letter-spacing: .04em; user-select: all; padding: 4px 8px; background: var(--surface-2); border-radius: 8px; }
.cert-or { text-align: center; margin: 14px 0 10px; }
#cert-box { margin-bottom: 8px; }
