/* OTM shared styles. Brand colours come from /brand.css (--brand-*). */
:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --text: #1c2330;
  --muted: #667085;
  --border: #dde2ea;
  --field: #ffffff;
  --ok: #1f8a4c;
  --ok-bg: #e8f6ee;
  --warn: #8a5a00;
  --warn-bg: #fff6e0;
  --bad: #c0362c;
  --bad-bg: #fdecea;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 16px rgba(16, 24, 40, .06);
  --focus: color-mix(in srgb, var(--brand-accent) 45%, transparent);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
main { flex: 1; }
a { color: var(--brand-primary); }
/* Pages use the full width of the screen (small forms keep their own width: .narrow, .narrow-wide) */
.wrap { width: 100%; max-width: none; margin: 0 auto; padding: 0 24px; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

.icon { width: 1.1em; height: 1.1em; vertical-align: -0.18em; fill: none; stroke: currentColor;
        stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-lg { width: 36px; height: 36px; flex: none; color: var(--brand-primary); }
.icon-lg.ok { color: var(--ok); }
.icon-lg.bad { color: var(--bad); }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.i { width: 1.15em; height: 1em; flex: none; fill: currentColor; }

/* Header: full width, company colours. Shared by the user portal and the admin portal, so it uses
   --tenant-* (never overridden by the admin theme) and a fixed font, making both look identical. */
.brand-header { background: var(--tenant-header-bg); color: var(--tenant-header-text);
                border-bottom: 4px solid var(--tenant-accent); padding: 22px 0;
                font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
.header-inner { display: flex; align-items: center; gap: 28px; padding: 0 28px; }
.logo { display: block; max-height: 76px; max-width: 220px; width: auto; height: auto; }
.header-text h1 { margin: 0; font-size: 1.75rem; line-height: 1.2; font-weight: 700; letter-spacing: -0.01em; }
.header-text h1 a { color: inherit !important; text-decoration: none; }
.header-text p { margin: 4px 0 0; color: var(--tenant-header-muted); }
.header-actions { margin-left: auto; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: flex-end; }
.header-actions form { margin: 0; }
.header-user { display: inline-flex; align-items: center; gap: 6px; font-size: .9rem; color: var(--tenant-header-muted); }

/* Below the header: Menu sidebar + main column */
.layout { display: flex; align-items: flex-start; }
/* The menu uses the company's header colours (--tenant-header-*), so it matches the top section */
.sidebar { flex: none; width: 220px; position: sticky; top: 0; align-self: stretch;
           background: var(--tenant-header-bg); color: var(--tenant-header-text);
           border-right: 1px solid color-mix(in srgb, var(--tenant-header-text) 12%, transparent); padding: 24px 12px; }
.side-title { margin: 0 0 10px; padding: 0 14px; font-size: .75rem; font-weight: 700; letter-spacing: .08em;
              text-transform: uppercase; color: var(--tenant-header-muted); }
.side-nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 10px;
            color: var(--tenant-header-text); text-decoration: none; font-weight: 600; }
.nav-item .i { font-size: 17px; width: 22px; color: var(--tenant-header-muted); }
.nav-item:hover { background: color-mix(in srgb, var(--tenant-header-text) 8%, transparent); }
.nav-item.active { color: var(--tenant-header-text); background: color-mix(in srgb, var(--tenant-header-text) 13%, transparent);
                   box-shadow: inset 3px 0 0 var(--tenant-accent); }
.nav-item.active .i { color: var(--tenant-accent); }
.nav-item:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }
.no-menu .sidebar { display: none; }

.main-col { flex: 1; min-width: 0; min-height: calc(100vh - 124px); display: flex; flex-direction: column; }
.page-header { padding-top: 24px; display: flex; align-items: flex-start; justify-content: space-between; gap: 16px 24px;
               flex-wrap: wrap; }
.page-title { min-width: 0; }
.page-header h1 { margin: 0; font-size: 1.5rem; line-height: 1.25; letter-spacing: -0.01em; }
.page-header p { margin: 4px 0 0; color: var(--muted); }

/* Steps */
/* A progress track, not buttons: flat boxes joined by arrows; reached steps light up in the company colour */
.steps { list-style: none; padding: 0; margin: 20px 0 20px; display: grid;
         grid-template-columns: repeat(4, 1fr); gap: 34px; }
.steps li { position: relative; display: flex; align-items: center; justify-content: center; gap: 10px;
            padding: 12px 10px; border-radius: var(--radius); border: 1px dashed var(--border);
            background: transparent; color: var(--muted); cursor: default; user-select: none;
            transition: background .25s, border-color .25s, color .25s; }
.steps li + li::before { content: ""; position: absolute; left: -24px; top: 50%; width: 11px; height: 11px;
                         border-top: 2.5px solid var(--border); border-right: 2.5px solid var(--border);
                         transform: translateY(-50%) rotate(45deg); }
.steps strong { font-size: .95rem; font-weight: 600; }
.step-num { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px;
            border-radius: 50%; font-size: .8rem; font-weight: 700; border: 1.5px solid currentColor; }
.step-icon { width: 26px; height: 22px; flex: none; fill: currentColor; opacity: .7; }
.steps li.done { border: 1px solid color-mix(in srgb, var(--brand-primary) 35%, var(--border));
                 background: color-mix(in srgb, var(--brand-primary) 9%, var(--card)); color: var(--brand-primary); }
.steps li.done .step-num { background: var(--brand-primary); border-color: var(--brand-primary); color: var(--brand-primary-text); }
.steps li.done .step-icon { fill: var(--brand-accent); opacity: 1; }
.steps li.done + li::before { border-color: var(--brand-primary); }
.steps li.current { border: 2px solid var(--brand-primary);
                    box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand-primary) 12%, transparent); }

/* Cards */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
        box-shadow: var(--shadow); padding: 28px; margin: 20px 0; }
.card h2 { margin: 0 0 16px; font-size: 1.35rem; line-height: 1.3; }
.card h3 { margin: 24px 0 8px; font-size: 1rem; }
.card p { margin: 0 0 14px; }
.success-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.success-head h2 { margin: 0; }

/* Forms */
.field { margin-bottom: 20px; }
.field label { display: block; font-weight: 600; margin-bottom: 6px; }
.label-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 6px; }
.label-row label, .label-row h2 { margin: 0; }
.counter { font-size: .85rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.counter.near { color: var(--bad); font-weight: 600; }
.hint { font-size: .875rem; color: var(--muted); margin: 6px 0 0; }

textarea, input[type=text], input[type=password] {
  width: 100%; font: inherit; color: var(--text); background: var(--field);
  border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px;
}
textarea { resize: vertical; min-height: 160px; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .95rem; }
textarea:focus, input:focus, button:focus-visible, a:focus-visible, .message:focus-visible {
  outline: 3px solid var(--focus); outline-offset: 1px; border-color: var(--brand-accent);
}
.options { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 32px; align-items: start; }
.options .option-password { grid-column: 1 / -1; max-width: calc(50% - 16px); }
.options .field { margin-bottom: 20px; }
.input-with-btn { display: flex; gap: 8px; }
.input-with-btn input { flex: 1; min-width: 0; }

.pill { background: color-mix(in srgb, var(--brand-primary) 10%, white); color: var(--brand-primary);
        font-weight: 700; font-size: .875rem; padding: 2px 10px; border-radius: 999px; font-variant-numeric: tabular-nums; }
input[type=range] { --fill: 31%; width: 100%; height: 28px; margin: 4px 0 0; background: transparent;
                    -webkit-appearance: none; appearance: none; cursor: pointer; }
input[type=range]::-webkit-slider-runnable-track { height: 6px; border-radius: 3px;
  background: linear-gradient(to right, var(--brand-primary) var(--fill), var(--border) var(--fill)); }
input[type=range]::-moz-range-track { height: 6px; border-radius: 3px; background: var(--border); }
input[type=range]::-moz-range-progress { height: 6px; border-radius: 3px; background: var(--brand-primary); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; margin-top: -7px;
  border-radius: 50%; background: #fff; border: 3px solid var(--brand-primary); }
input[type=range]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: #fff;
  border: 3px solid var(--brand-primary); }
.range-ends { display: flex; justify-content: space-between; font-size: .8rem; color: var(--muted); }

fieldset.field { border: 0; padding: 0; margin: 0 0 20px; min-width: 0; }
fieldset.field legend { font-weight: 600; margin-bottom: 6px; padding: 0; }
.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border: 1px solid var(--border);
             border-radius: 8px; overflow: hidden; background: var(--field); }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label { margin: 0; padding: 8px 0; text-align: center; font-weight: 600; cursor: pointer;
                   font-variant-numeric: tabular-nums; border-left: 1px solid var(--border); color: var(--muted); }
.segmented label:first-of-type { border-left: 0; }
.segmented label:hover { background: var(--bg); }
.segmented input:checked + label { background: var(--brand-primary); color: var(--brand-primary-text); }
.segmented input:focus-visible + label { outline: 3px solid var(--focus); outline-offset: -3px; }

/* Buttons */
button, .btn-secondary { font: inherit; cursor: pointer; border-radius: 8px; padding: 10px 18px;
                         border: 1px solid transparent; font-weight: 600; text-decoration: none; gap: 8px;
                         display: inline-flex; align-items: center; justify-content: center; white-space: nowrap; }
.btn-sm { padding: 6px 12px; font-size: .875rem; }
button:disabled { opacity: .6; cursor: not-allowed; }
.btn-primary { background: var(--brand-primary); color: var(--brand-primary-text); }
.btn-primary:hover:not(:disabled) { filter: brightness(1.12); }
.btn-primary.copied { background: var(--ok); }
.btn-lg { width: 100%; padding: 14px 20px; font-size: 1.05rem; }
.btn-secondary { background: var(--card); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg); }
.btn-ghost { background: transparent; color: var(--muted); border-color: var(--border); font-weight: 500; }
.btn-danger-ghost { background: transparent; color: var(--bad); border-color: color-mix(in srgb, var(--bad) 35%, white); }
.btn-danger-ghost:hover:not(:disabled) { background: var(--bad-bg); }

/* Result */
.result-head { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; }
.result-head h2 { margin: 0 0 2px; }
.result-head p { margin: 0; }
.result-head > div { flex: 1; min-width: 0; }
.result-badge.bad { color: var(--bad); background: var(--bad-bg); }
.head-action { flex: none; }
.pw-open { max-width: 420px; }
.result-badge { flex: none; width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center;
                font-size: 22px; color: var(--brand-accent);
                background: color-mix(in srgb, var(--brand-accent) 12%, white); }
#links { margin: 0 0 12px; }
.link-box { display: flex; gap: 8px; margin: 0 0 10px; align-items: stretch; }
.link-box .link-tag { align-self: center; }
.link-tag { flex: none; width: 56px; font-size: .85rem; font-weight: 600; color: var(--muted); }
.link-box input { flex: 1; min-width: 0; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
                  font-size: .9rem; background: var(--bg); padding: 12px 14px; }
.link-box button, .link-box .btn-mail { padding: 12px 18px; }
.btn-mail .i { color: var(--brand-primary); }
.copy-all { margin: 0 0 4px; }

.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 20px 0 16px; }
.tile { display: flex; gap: 12px; align-items: flex-start; border: 1px solid var(--border); border-radius: 10px;
        padding: 14px; background: var(--bg); }
.tile > .i { font-size: 18px; margin-top: 2px; color: var(--brand-accent); }
.tile > div { min-width: 0; }
.tile-label { display: block; font-size: .75rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
              color: var(--muted); }
.tile strong { display: block; font-size: 1rem; line-height: 1.35; }
.tile-sub { display: block; font-size: .8rem; color: var(--muted); }

.notice { display: flex; align-items: center; gap: 10px; font-size: .9rem; color: var(--warn);
          margin: 0 0 20px !important; }
.notice .i { color: #d99a00; }
.actions { display: flex; gap: 12px; flex-wrap: wrap; justify-content: space-between;
           border-top: 1px solid var(--border); padding-top: 20px; }
#gone .actions { border-top: 0; padding-top: 0; }

.alert { border-radius: 8px; padding: 10px 14px; font-size: .925rem; margin: 0 0 16px; }
.alert.error { background: var(--bad-bg); color: var(--bad); }
.alert.warn { background: var(--warn-bg); color: var(--warn); }
.alert.ok { background: var(--ok-bg); color: var(--ok); }
.actions + .alert { margin-top: 16px; margin-bottom: 0; }

.message { white-space: pre-wrap; word-break: break-word; background: var(--bg); border: 1px solid var(--border);
           border-radius: 8px; padding: 14px; margin: 12px 0 16px; max-height: 60vh; overflow: auto;
           font: .95rem/1.5 ui-monospace, "Cascadia Mono", Consolas, monospace; }

/* Admin */
.narrow { max-width: 460px; }
.narrow-wide { max-width: 640px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0;
              border-bottom: 1px solid var(--border); cursor: pointer; }
.switch-row.is-fixed { cursor: default; opacity: .75; }
.switch-row:last-of-type { margin-bottom: 20px; }
.switch-row strong { display: block; }
.switch-row .muted { display: block; font-size: .85rem; }
.switch { -webkit-appearance: none; appearance: none; flex: none; width: 46px; height: 26px; border-radius: 13px;
          background: var(--border); position: relative; cursor: pointer; transition: background .15s; margin: 0; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
                 background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform .15s; }
.switch:checked { background: var(--brand-primary); }
.switch:checked::after { transform: translateX(20px); }
.switch:disabled { cursor: default; }
.switch:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .925rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; }
td .muted { font-size: .8rem; display: block; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Footer */
.footer { padding-top: 8px; padding-bottom: 32px; text-align: center; font-size: .875rem; color: var(--muted); }
.footer p { margin: 4px 0; }
.footer .i { vertical-align: -0.15em; }

@media (max-width: 900px) {
  .layout { flex-direction: column; align-items: stretch; }
  .sidebar { position: static; width: auto; border-right: 0; padding: 8px 12px;
             border-bottom: 1px solid color-mix(in srgb, var(--tenant-header-text) 12%, transparent); }
  .side-title { display: none; }
  .side-nav { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); }
  .nav-item { justify-content: center; gap: 8px; padding: 8px 6px; font-size: .9rem; white-space: nowrap; }
  .nav-item.active { box-shadow: inset 0 -3px 0 var(--tenant-accent); }
  .main-col { min-height: 0; }
}

@media (max-width: 800px) {
  .steps { gap: 22px; }
  .steps li + li::before { left: -17px; width: 8px; height: 8px; }
  .steps li { flex-direction: column; gap: 4px; padding: 10px 4px; text-align: center; }
  .step-icon { display: none; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .options { grid-template-columns: 1fr; gap: 0; }
  .options .option-password { max-width: none; }
}

@media (max-width: 640px) {
  .brand-header { padding: 16px 0; }
  .header-inner { flex-direction: column; align-items: flex-start; gap: 10px; padding: 0 16px; }
  .logo { max-height: 52px; }
  .header-text h1 { font-size: 1.35rem; }
  .page-header h1 { font-size: 1.3rem; }
  .nav-item { font-size: .82rem; gap: 6px; padding: 8px 2px; }
  .nav-item .i { font-size: 14px; width: 16px; }
  .steps { margin-top: 16px; }
  .steps strong { font-size: .75rem; line-height: 1.2; }
  .card { padding: 20px 16px; }
  .link-box { flex-wrap: wrap; }
  .link-box input { flex-basis: 100%; }
  .link-box button { width: 100%; }
  .link-tag { width: auto; }
  .actions { flex-direction: column; }
  .actions button, .actions a { width: 100%; }
  .result-head { flex-wrap: wrap; }
  .head-action { width: 100%; }
}

/* ---- Admin area: dark theme, same palette as the NDM project ---------------- */
.admin-theme {
  --bg: #161925; --card: #1e2233; --field: #252a3d; --border: #313650;
  --text: #e4e6f0; --muted: #8890ab;
  --ok: #3ddc84; --ok-bg: rgba(61, 220, 132, .12);
  --warn: #f0c674; --warn-bg: rgba(240, 198, 116, .12);
  --bad: #ff6b7a; --bad-bg: rgba(255, 107, 122, .12);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  --brand-primary: #7c3aed; --brand-primary-text: #ffffff; --brand-accent: #8b9cf5;
  --admin-blue: #089fe8;
  --focus: rgba(139, 156, 245, .5);
  min-height: 100vh; font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}
.admin-theme a { color: var(--brand-accent); }
.admin-theme a:hover { color: #aab6f8; }
.admin-theme .result-badge { background: rgba(139, 156, 245, .14); }
.admin-theme .btn-primary:hover:not(:disabled) { filter: none; background: #6d28d9; }
.admin-theme .btn-secondary { background: var(--field); }
.admin-theme .btn-secondary:hover { border-color: var(--brand-accent); color: #aab6f8; background: var(--field); }
.admin-theme .tile { background: var(--field); }
.admin-theme .switch { background: var(--border); }
.admin-theme .switch:checked { background: var(--brand-primary); }
.admin-theme th { background: var(--field); }
.admin-theme input[type=text], .admin-theme input[type=password] { background: var(--field); }

.admin-layout { display: flex; align-items: flex-start; gap: 28px; padding: 24px; }
.admin-nav { flex: none; width: 230px; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 24px; }
.admin-nav-title { margin: 16px 0 6px; padding: 0 12px; font-size: .72rem; font-weight: 700; letter-spacing: .08em;
                   text-transform: uppercase; color: var(--muted); }
.admin-nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 6px;
               color: var(--text); text-decoration: none; }
.admin-nav a .i { color: var(--muted); font-size: 16px; }
.admin-nav a:hover { background: var(--field); color: var(--text); }
.admin-nav a.active { background: var(--field); color: var(--brand-accent); font-weight: 600;
                      box-shadow: inset 3px 0 0 var(--brand-accent); }
.admin-nav a.active .i { color: var(--brand-accent); }
.admin-nav .chev { margin-left: auto; color: var(--muted); font-size: 1.1rem; line-height: 1; }
.tag + .chev { margin-left: 8px; }
/* "All modules": under the module name, lit up in the admin accent colour */
.admin-nav a.admin-back { color: #c3ccff !important; font-size: .9rem; font-weight: 600; margin: 0 0 8px;
                          background: rgba(139, 156, 245, .14); border: 1px solid rgba(139, 156, 245, .4); }
.admin-nav a.admin-back .i { color: #aab6f8; }
.admin-nav a.admin-back:hover { color: #fff !important; background: rgba(139, 156, 245, .26); border-color: #8b9cf5; }
.admin-nav-module { display: flex; align-items: center; gap: 10px; padding: 10px 12px 14px; margin-bottom: 6px;
                    border-bottom: 1px solid var(--border); }
.admin-nav-module .result-badge { width: 36px; height: 36px; border-radius: 10px; font-size: 16px; color: var(--brand-accent); }
.admin-nav-module strong { display: block; font-size: 1rem; line-height: 1.2; margin-bottom: 2px; }
.tag { margin-left: auto; font-size: .7rem; font-weight: 700; padding: 1px 7px; border-radius: 999px;
       background: var(--border); color: var(--muted); }

.admin-main { flex: 1; min-width: 0; }
.admin-main > .alert { margin-bottom: 16px; }
.admin-crumbs ol { list-style: none; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 14px;
                   padding: 0; font-size: .85rem; color: var(--muted); }
.admin-crumbs li + li::before { content: "›"; margin-right: 8px; color: var(--muted); }
.admin-crumbs a { color: var(--brand-accent); font-weight: 600; text-decoration: none; }
.admin-crumbs a:hover { text-decoration: underline; }
.admin-crumbs [aria-current] { color: var(--text); font-weight: 600; }
.admin-h1 { display: flex; align-items: center; gap: 12px; margin: 0 0 16px; font-size: 1.4rem; font-weight: 600; }
.admin-h1 .muted { font-size: 1rem; font-weight: 400; }
.admin-main .card { margin: 0 0 20px; }
.admin-main .tiles { margin: 0 0 20px; }
.admin-login { margin: 40px auto; }

.module-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.module-card { display: flex; gap: 14px; align-items: flex-start; margin: 0 !important; text-decoration: none;
               color: var(--text) !important; transition: border-color .15s; }
.module-card:hover { border-color: var(--brand-accent); }
.module-card strong { font-size: 1.05rem; margin-right: 8px; }
.module-card p { margin: 6px 0 0; font-size: .875rem; }
.status { display: inline-block; font-size: .72rem; font-weight: 700; padding: 1px 8px; border-radius: 999px;
          vertical-align: 2px; }
.status.on { background: var(--ok-bg); color: var(--ok); }
.status.off { background: var(--border); color: var(--muted); }

@media (max-width: 800px) {
  .admin-layout { flex-direction: column; gap: 16px; padding: 16px; }
  .admin-nav { position: static; width: 100%; flex-direction: row; flex-wrap: wrap; gap: 4px; }
  .admin-nav-title { display: none; }
  .admin-nav-module { width: 100%; padding: 4px 4px 10px; }
  .admin-back { margin-bottom: 0; }
  .admin-nav a { padding: 7px 10px; font-size: .9rem; }
}

/* ---- Secure Notes: channels ------------------------------------------------ */
.channel-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; margin: 20px 0; }
.channel-card { display: flex; align-items: center; gap: 14px; margin: 0; text-decoration: none; color: var(--text);
                transition: border-color .15s, transform .15s; }
.channel-card:hover { border-color: var(--brand-accent); transform: translateY(-1px); }
.channel-card strong { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.channel-card .lock { color: var(--muted); }
.page-header p a { color: inherit; }

/* admin */
.channel-create { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 20px; align-items: end; }
.channel-create .switch-row, .channel-create button { grid-column: 1 / -1; }
.channel-create button { justify-self: start; }
.switch-row.inline { border-bottom: 0; padding-top: 0; }
.count { font-size: .9rem; font-weight: 400; margin-left: 6px; }
.channel-list { display: flex; flex-direction: column; }
.channel-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
               padding: 14px 0; border-top: 1px solid var(--border); }
.channel-info { display: flex; align-items: center; gap: 12px; min-width: 0; }
.channel-info .result-badge { width: 38px; height: 38px; border-radius: 10px; font-size: 16px; color: var(--brand-accent); }
.channel-info strong { display: block; overflow-wrap: anywhere; }
.channel-info .muted { font-size: .8rem; }
.channel-actions { display: flex; align-items: flex-start; gap: 8px; flex-wrap: wrap; }
.channel-actions form { margin: 0; }
.state-btn { padding: 5px 12px; font-size: .85rem; border-radius: 999px; gap: 7px; background: var(--field);
             border: 1px solid var(--border); color: var(--muted); }
.state-btn .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.state-btn.on { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); background: var(--ok-bg); }
.state-btn.on .dot { background: var(--ok); }
.state-btn:hover { border-color: var(--brand-accent); }
.pw-change summary { list-style: none; cursor: pointer; }
.pw-change summary::-webkit-details-marker { display: none; }
.pw-change[open] summary { border-color: var(--brand-accent); }
.pw-change form { display: flex; flex-direction: column; gap: 8px; margin-top: 8px !important; padding: 12px;
                  background: var(--field); border: 1px solid var(--border); border-radius: 8px; min-width: 260px; }
.pw-change button { align-self: flex-start; }

@media (max-width: 800px) {
  .channel-create { grid-template-columns: 1fr; }
}

/* ---- Switch between the user portal and the admin portal (top right) ---------- */
.portal-switch { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 8px;
                 font-family: inherit; font-size: .9rem; font-weight: 600; line-height: 1.2; text-decoration: none; white-space: nowrap; cursor: pointer;
                 color: var(--tenant-header-text) !important;
                 border: 1px solid color-mix(in srgb, var(--tenant-header-text) 35%, transparent);
                 background: color-mix(in srgb, var(--tenant-header-text) 8%, transparent); }
.portal-switch:hover { background: color-mix(in srgb, var(--tenant-header-text) 16%, transparent); }

@media (max-width: 640px) {
  .brand-header .header-inner { position: relative; }
  .header-actions { position: absolute; top: 0; right: 16px; gap: 6px; }
  .portal-switch { padding: 6px 10px; font-size: .8rem; }
  .header-user { display: none; }
}

/* ---- Secure Notes: channel notepad (tabs + editor, like ProtectedText) --------- */
.status.warn { background: var(--warn-bg); color: var(--warn); }
.editor-card { padding: 16px 20px 20px; }
.editor-bar { display: flex; align-items: center; justify-content: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; align-items: flex-end; min-width: 0; margin-top: 14px;
        border-bottom: 1px solid var(--border); }
.tab { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; font-size: .875rem; font-weight: 600;
       border: 1px solid var(--border); border-bottom: 0; border-radius: 8px 8px 0 0; background: var(--bg);
       color: var(--muted); max-width: 220px; overflow: hidden; text-overflow: ellipsis; margin-bottom: -1px; }
.tab.active { background: var(--card); color: var(--text); border-bottom: 1px solid var(--card); }
.tab:hover:not(.active) { color: var(--text); }
.tab-add { padding: 8px 12px; font-size: 1rem; }
.tab-close { font-size: 1.1rem; line-height: 1; color: var(--muted); padding: 0 2px; border-radius: 4px; }
.tab-close:hover { color: var(--bad); background: var(--bad-bg); }
.editor-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.save-state { font-size: .8rem; color: var(--muted); margin-right: 6px; white-space: nowrap; }
.save-state.dirty { color: var(--warn); font-weight: 600; }
.save-state.saved { color: var(--ok); }
.pad { display: block; width: 100%; min-height: 60vh; margin-top: 0; resize: vertical; border-top: 0;
       border-top-left-radius: 0 !important;
       font: .95rem/1.55 ui-monospace, "Cascadia Mono", Consolas, monospace; border-radius: 8px; }
.editor-card .alert { margin: 12px 0 0; }
.editor-card .alert .btn-sm { margin-left: 6px; }
.admin-pw-note { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 0 0 14px !important;
                 padding: 12px 14px; font-weight: 600; border: 1px solid color-mix(in srgb, var(--bad) 45%, transparent);
                 border-left-width: 4px; }
.admin-pw-note .i { flex: none; font-size: 18px; }
.admin-pw-note span { flex: 1; min-width: 200px; }
.admin-pw-note .btn-secondary { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, transparent); }
.pw-panel { margin-top: 12px; padding: 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); }
.pw-panel p { margin: 4px 0 10px; font-size: .875rem; }
.pw-fields { display: flex; gap: 8px; flex-wrap: wrap; }
.pw-fields input { flex: 1; min-width: 200px; }
.pw-change .alert { margin: 0; font-size: .8rem; }

@media (max-width: 640px) {
  .editor-card { padding: 12px; }
  .editor-actions { width: 100%; }
  .pad { min-height: 50vh; }
}

/* ---- Secure Notes portal: channel table + search ------------------------------ */
.table-tools { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.search { flex: 1; min-width: 240px; max-width: 560px; display: flex; align-items: center; gap: 12px; height: 50px;
          padding: 0 16px; margin: 0; cursor: text; border: 1.5px solid var(--border); border-radius: 12px;
          background: var(--field); color: var(--muted); box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
          transition: border-color .15s, box-shadow .15s; }
.search .i { font-size: 18px; flex: none; }
.search:hover { border-color: color-mix(in srgb, var(--brand-primary) 40%, var(--border)); }
.search:focus-within { border-color: var(--brand-primary); color: var(--brand-primary);
                       box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand-primary) 15%, transparent); }
.search input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: transparent;
                font: inherit; font-size: 1.05rem; color: var(--text); padding: 0; }
.search input::placeholder { color: var(--muted); }
.search input::-webkit-search-cancel-button { cursor: pointer; }
.search-count { margin-left: auto; font-size: .875rem; font-weight: 600; color: var(--muted); padding: 6px 12px;
                border-radius: 999px; background: var(--bg); white-space: nowrap; }
.channel-table td { vertical-align: middle; padding: 12px 10px; }
.channel-table tbody tr:hover { background: var(--bg); }
.channel-link { display: inline-flex; align-items: center; gap: 10px; font-weight: 600; color: var(--text); text-decoration: none; }
.channel-link .i { color: var(--brand-accent); }
.channel-link:hover { color: var(--brand-primary); }
.no-results { margin: 8px 0 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (max-width: 640px) {
  .search { max-width: none; height: 46px; }
  .search-count { margin-left: 0; }
}

/* ---- Admin: channel table, create button, dialogs -------------------------------- */
.admin-h1-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.admin-h1-row .admin-h1 { margin: 0; }
.form-buttons { display: flex; gap: 10px; grid-column: 1 / -1; }
.admin-theme .search { background: var(--field); }
.admin-theme .search-count { background: var(--field); }
.admin-theme .channel-table tbody tr:hover { background: var(--field); }
.admin-channel-table td form { margin: 0; }
.pw-locked { display: inline-flex; align-items: center; gap: 6px; font-size: .85rem; color: var(--muted); white-space: nowrap; }
.pw-locked .i { color: var(--brand-accent); }
.btn-danger { background: var(--bad); color: #fff; }
.btn-danger:hover:not(:disabled) { filter: brightness(1.1); }

.admin-dialog { width: min(460px, calc(100vw - 32px)); padding: 24px; border: 1px solid var(--border); border-radius: 14px;
                background: var(--card); color: var(--text); box-shadow: 0 20px 60px rgba(0, 0, 0, .5); }
.admin-dialog::backdrop { background: rgba(10, 12, 20, .7); }
.admin-dialog h2 { margin: 0 0 10px; font-size: 1.2rem; }
.admin-dialog p { margin: 0 0 16px; }
.admin-dialog label { display: block; font-weight: 600; margin-bottom: 6px; }
.admin-dialog input { width: 100%; }
.admin-dialog .alert { margin: 12px 0 0; }
.dialog-buttons { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.channel-link { white-space: nowrap; }

/* ---- Admin: OTM settings -------------------------------------------------------------- */
.settings-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.settings-grid .card { margin: 0; }
.settings-grid h2 { display: flex; align-items: center; gap: 10px; }
.settings-grid h2 .i { color: var(--brand-accent); }
.num-fields { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.num-fields input { width: 100%; font: inherit; color: var(--text); background: var(--field);
                    border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }
.num-fields input:focus { outline: 3px solid var(--focus); border-color: var(--brand-accent); }
.hard-limit { font-size: .8rem; color: var(--muted); margin: 10px 0 0 !important; }
.settings-actions { margin-top: 20px; }
@media (max-width: 900px) { .settings-grid { grid-template-columns: 1fr; } }
.pw-flag { margin-left: 8px; font-size: 13px; color: var(--muted); vertical-align: -1px; }

/* ---- Admin: Active OTM selection --------------------------------------------------- */
.check-col { width: 42px; }
.row-check { width: 18px; height: 18px; accent-color: var(--brand-primary); cursor: pointer; vertical-align: middle; }
.bulk-hint { margin: -6px 0 14px !important; }
#bulk-delete:disabled { opacity: .45; }

/* ---- Admin: Secure Notes settings --------------------------------------------------- */
.inline-number { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.inline-number label { margin: 0; }
.inline-number input { width: 120px; font: inherit; font-size: 1.05rem; color: var(--text); background: var(--field);
                       border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }
.inline-number input:focus { outline: 3px solid var(--focus); border-color: var(--brand-accent); }
.auto-delete { display: block; font-size: .75rem; color: var(--muted); margin-top: 2px; }
.card h2 .i { color: var(--brand-accent); vertical-align: -2px; }

/* ---- Secure Notes: auto-delete notice ------------------------------------------ */
.expiry-note { display: flex; align-items: center; gap: 10px; margin: 0 0 12px !important; padding: 9px 12px;
               border-radius: 8px; font-size: .875rem; color: var(--muted); background: var(--bg);
               border: 1px solid var(--border); }
.expiry-note .i { flex: none; color: var(--brand-accent); }
#locked .expiry-note { margin: 14px 0 0 !important; }
.num-fields.one { grid-template-columns: minmax(0, 220px); }

/* ---- Secure Chat ------------------------------------------------------------------------ */
/* Chat colours: 0 red, 1 blue, 2 yellow, 3 green, 4 orange, 5 purple, 6 pink, 7 brown, 8 black, 9 gray */
.c0 { --who: #dc2626; } .c1 { --who: #2563eb; } .c2 { --who: #ca8a04; } .c3 { --who: #16a34a; } .c4 { --who: #ea580c; }
.c5 { --who: #9333ea; } .c6 { --who: #db2777; } .c7 { --who: #92400e; } .c8 { --who: #111827; } .c9 { --who: #6b7280; }
.chat-card { padding: 16px 20px 20px; }
.chat-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.chat-members { display: flex; gap: 6px; flex-wrap: wrap; }
.member { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: .85rem;
          font-weight: 600; color: var(--who); background: color-mix(in srgb, var(--who) 10%, transparent); }
.member .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--who); }
.member em { font-style: normal; font-size: .7rem; text-transform: uppercase; letter-spacing: .04em; opacity: .8; }
.chat-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.chat-body { display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: 16px; align-items: start; }
#chat.editing .chat-body { display: none; }
.chat-people { border: 1px solid var(--border); border-radius: 12px; background: var(--bg); padding: 12px 14px; }
.people-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.people-head .muted { font-size: .75rem; }
.people-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.person { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; font-weight: 600;
          font-size: .9rem; color: var(--who); background: color-mix(in srgb, var(--who) 8%, transparent); }
.person .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person em { margin-left: auto; font-style: normal; font-size: .65rem; text-transform: uppercase; letter-spacing: .04em;
             opacity: .8; }
.online-dot { flex: none; display: inline-block; width: 10px; height: 10px; min-width: 10px; padding: 0;
              border-radius: 50%; aspect-ratio: 1; }
.online-dot.on { background: #22c55e; box-shadow: 0 0 6px 2px rgba(34, 197, 94, .55); }
.online-dot.off { background: #ef4444; box-shadow: 0 0 6px 2px rgba(239, 68, 68, .45); }
.people-legend { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: .75rem; margin: 10px 0 0 !important; }
.people-legend .online-dot { width: 8px; height: 8px; min-width: 8px; }
.people-legend .online-dot.off { margin-left: 10px; }
.unit-label { align-self: center; }
#idle-minutes { max-width: 110px; flex: 0 0 110px; }

.messages { height: 58vh; min-height: 280px; overflow-y: auto; padding: 16px; border: 1px solid var(--border);
            border-radius: 12px; background: var(--bg); display: flex; flex-direction: column; gap: 10px; }
.msg { display: flex; }
.msg.mine { justify-content: flex-end; }
.bubble { max-width: min(75%, 640px); padding: 8px 12px 10px; border-radius: 14px 14px 14px 4px; background: var(--card);
          border: 1px solid color-mix(in srgb, var(--who) 30%, var(--border));
          box-shadow: inset 3px 0 0 var(--who); }
.msg.mine .bubble { border-radius: 14px 14px 4px 14px; background: color-mix(in srgb, var(--who) 12%, var(--card));
                    box-shadow: inset -3px 0 0 var(--who); }
.msg-head { display: flex; align-items: baseline; gap: 8px; font-size: .75rem; color: var(--muted); margin-bottom: 2px; }
.msg-head strong { color: var(--who); font-size: .8rem; }
.msg-del { margin-left: auto; padding: 0 4px; font-size: 1rem; line-height: 1; border: 0; background: none; color: var(--muted);
           opacity: 0; transition: opacity .15s; }
.msg:hover .msg-del, .msg-del:focus-visible { opacity: 1; }
.msg-del:hover { color: var(--bad); }
.msg-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: .95rem; line-height: 1.45; }
.system-note { align-self: center; font-size: .8rem; color: var(--muted); background: var(--card); padding: 4px 12px;
               border-radius: 999px; border: 1px solid var(--border); margin: 0; }
.history-note { font-size: .8rem; margin: 6px 0 10px !important; }
.composer { display: flex; gap: 10px; align-items: flex-end; }
.composer textarea { flex: 1; min-height: 52px; max-height: 200px; resize: vertical; font-family: inherit; }
.composer button { height: 52px; padding: 0 24px; }
.users-panel { margin-bottom: 12px; }
.users-panel .sub { display: block; margin: 12px 0 8px; }
.user-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.user-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 6px 0; border-bottom: 1px solid var(--border); }
.user-row .muted { font-size: .8rem; flex: 1; }

/* Dialogs on the user portal (light) */
.app-dialog { width: min(440px, calc(100vw - 32px)); padding: 22px; border: 1px solid var(--border); border-radius: 14px;
              background: var(--card); color: var(--text); box-shadow: 0 20px 60px rgba(16, 24, 40, .25); }
.app-dialog::backdrop { background: rgba(16, 24, 40, .45); }
.app-dialog h2 { margin: 0 0 8px; font-size: 1.15rem; }
.app-dialog p { margin: 0 0 12px; }
.app-dialog label { display: block; font-weight: 600; margin-bottom: 6px; }
.app-dialog input { width: 100%; margin-bottom: 8px; }
.app-dialog .alert { margin: 8px 0 0; }

/* Select boxes (admin forms) */
select { font: inherit; color: var(--text); background: var(--field); border: 1px solid var(--border); border-radius: 8px;
         padding: 10px 12px; width: 100%; }
select:focus { outline: 3px solid var(--focus); border-color: var(--brand-accent); }

@media (max-width: 860px) {
  .chat-body { grid-template-columns: 1fr; }
  .chat-people { order: -1; padding: 8px 10px; }
  .people-list { flex-direction: row; flex-wrap: wrap; }
  .people-legend { display: none; }
}
@media (max-width: 640px) {
  .chat-card { padding: 12px; }
  .bubble { max-width: 88%; }
  .messages { height: 55vh; padding: 10px; }
}

/* ---- Secure Chat: auto-delete switch and the Edit panel -------------------------------- */
.auto-toggle { height: 52px; display: inline-flex; align-items: center; gap: 8px; padding: 0 14px; border-radius: 10px;
               border: 0; color: #fff; font: inherit; cursor: pointer; transition: background .15s; }
.auto-toggle.on { background: #16a34a; }
.auto-toggle.on:hover:not(:disabled) { background: #15803d; }
.auto-toggle.off { background: #dc2626; }
.auto-toggle.off:hover:not(:disabled) { background: #b91c1c; }
.auto-toggle:disabled { opacity: .7; cursor: wait; }
.auto-toggle:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.auto-toggle .i { width: 18px; height: 18px; }
.auto-text { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.15; }
.auto-text span { font-size: .72rem; opacity: .9; }
.auto-text strong { font-size: .9rem; white-space: nowrap; }
.composer .auto-toggle { padding: 0 14px; }
.btn-purple { background: #7c3aed; color: #fff; border-color: #7c3aed; }
.btn-purple:hover:not(:disabled) { background: #6d28d9; border-color: #6d28d9; }
.edit-panel .edit-section { margin-top: 12px; }
.edit-panel .edit-section .sub { display: block; margin-bottom: 2px; }
.edit-panel .edit-section p { margin: 0 0 8px; font-size: .85rem; }
.edit-panel select { width: auto; }
#disappear-amount { max-width: 110px; flex: 0 0 110px; }
.color-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; cursor: pointer;
          font-size: .85rem; font-weight: 600; color: var(--who); border: 2px solid transparent;
          background: color-mix(in srgb, var(--who) 10%, transparent); }
.swatch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.swatch .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--who); }
.swatch:has(input:checked) { border-color: var(--who); background: color-mix(in srgb, var(--who) 18%, transparent); }
.swatch:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.dialog-buttons.start { justify-content: flex-start; margin-top: 14px; }
.msg-timer { font-size: 11px; color: var(--muted); }
@media (max-width: 640px) {
  .auto-text span { display: none; }
  .composer button, .composer .auto-toggle { padding: 0 12px; }
}

/* ---- Secure Chat: images ------------------------------------------------------------------ */
.attach-btn { height: 52px; width: 52px; flex: none; display: inline-flex; align-items: center; justify-content: center;
              border-radius: 10px; border: 1px solid var(--border); background: var(--card); color: var(--brand-primary);
              cursor: pointer; }
.attach-btn:hover { background: var(--bg); }
.attach-btn .i { width: 20px; height: 20px; }
.attach-btn:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.attach-preview { display: flex; align-items: center; gap: 12px; padding: 8px 10px; margin-bottom: 8px;
                  border: 1px dashed var(--border); border-radius: 10px; background: var(--bg); }
.attach-preview img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; background: var(--card); flex: none; }
.attach-info { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.attach-info strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .9rem; }
.attach-info .muted { font-size: .8rem; }
.msg-image { margin-top: 4px; }
.img-thumb { position: relative; display: block; max-width: 100%; padding: 0; border: 0; background: none; cursor: zoom-in; }
.img-thumb img { display: block; max-width: 100%; height: auto; min-width: 80px; min-height: 60px; border-radius: 10px;
                 background: color-mix(in srgb, var(--who) 10%, var(--bg)); object-fit: cover; }
.img-status { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 6px;
              font-size: .8rem; color: var(--muted); text-align: center; }
.img-thumb.failed { cursor: default; }
#chat.drag-over .messages { outline: 3px dashed var(--brand-accent); outline-offset: -6px; }
.image-dialog { width: min(96vw, 1100px); max-width: none; padding: 12px; }
.image-dialog img { display: block; max-width: 100%; max-height: calc(92vh - 90px); margin: 0 auto; border-radius: 8px;
                    object-fit: contain; }
.image-dialog .dialog-buttons { margin-top: 10px; align-items: center; }
.image-dialog .img-name { margin-right: auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
                          color: var(--muted); font-size: .85rem; }
.image-dialog a.btn-secondary { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; }
@media (max-width: 640px) {
  .attach-btn { width: 44px; }
}
.room-images span { display: block; white-space: nowrap; }
.room-images .muted { font-size: .75rem; }
.room-images .quota-full { color: var(--bad); font-weight: 600; }
/* Chat room page: use the whole screen (width, and the message list grows with the window height) */
.wide .messages { height: calc(100vh - 470px); min-height: 320px; }
.wide .bubble { max-width: min(75%, 760px); }
@media (min-width: 1400px) { .wide .chat-body { grid-template-columns: minmax(0, 1fr) 260px; } }
@media (max-width: 640px) { .wrap { padding: 0 12px; } .wide .messages { height: 55vh; } }
.size-state { font-size: .8rem; color: var(--muted); white-space: nowrap; }
.size-state.full { color: var(--bad); font-weight: 600; }
/* "Open by name" box above the channel/room lists (reaches hidden ones too) */
.open-card { padding-top: 18px; padding-bottom: 18px; }
.open-by-name { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.open-by-name .search { max-width: 640px; }
.open-by-name .btn-primary { height: 50px; padding: 0 22px; }
.open-card .alert { margin: 12px 0 0; }
/* Secure Notes "Hide from list": green while the channel is hidden */
#hide-btn.is-hidden { background: #16a34a; border-color: #16a34a; color: #fff; }
#hide-btn.is-hidden:hover:not(:disabled) { background: #15803d; border-color: #15803d; }
.inline-number select { width: auto; min-width: 90px; }
/* Admin > About: current version by category; older versions behind the Changelog button */
.changelog-date { font-size: .85rem; font-weight: 400; }
.changelog-cat { margin: 14px 0 4px; font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; }
.changelog-cat:first-of-type { margin-top: 4px; }
.changelog-features { color: var(--ok); }
.changelog-fixes { color: var(--warn); }
.changelog-changes { color: var(--brand-accent); }
.changelog { margin: 0; padding-left: 20px; }
.changelog li { margin: 3px 0; }
.changelog-all { margin-top: 22px; }
.changelog-all > summary { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; list-style: none; }
.changelog-all > summary::-webkit-details-marker { display: none; }
.changelog-all[open] > summary { margin-bottom: 6px; }
.changelog-old { border-top: 1px solid var(--border); margin-top: 14px; padding-top: 4px; }
.changelog-version { margin: 10px 0 2px; font-size: 1rem; }
.changelog-version .muted { font-weight: 400; font-size: .85rem; }
/* Friendly note at the top right of the Secure Notes / Secure Chat lists */
.page-note { display: flex; align-items: flex-start; gap: 12px; max-width: 380px; padding: 12px 16px; border-radius: 12px;
             background: color-mix(in srgb, var(--brand-primary) 7%, var(--card));
             border: 1px solid color-mix(in srgb, var(--brand-primary) 22%, var(--border)); }
.page-note .i { flex: none; width: 20px; height: 20px; margin-top: 2px; color: var(--brand-primary); }
.page-note strong { display: block; font-size: .92rem; }
.page-note span { display: block; font-size: .85rem; color: var(--muted); margin-top: 2px; }
@media (max-width: 640px) { .page-note { max-width: none; width: 100%; } }
/* Admin > Secure Notes / Secure Chat > Settings: compact cards, left to right, wrapping to the next line */
.settings-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; align-items: stretch; }
.settings-tiles .card { max-width: none; margin: 0; padding: 18px 20px; display: flex; flex-direction: column; }
.settings-tiles .card h2 { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; font-size: 1.05rem; }
.settings-tiles .card p.muted { font-size: .85rem; margin: 0 0 12px; }
.settings-tiles .inline-number { gap: 8px 10px; font-size: .9rem; }
.settings-tiles .inline-number input { width: 90px; font-size: .95rem; padding: 7px 10px; }
.settings-tiles .inline-number select { padding: 7px 10px; }
.settings-tiles .field { margin-bottom: 8px; }
.settings-tiles .switch-row { padding: 9px 0; font-size: .9rem; }
.settings-tiles .alert { font-size: .85rem; margin: 10px 0 0; }
.settings-tiles .settings-actions { margin-top: auto; padding-top: 14px; }   /* buttons line up at the bottom */
.settings-tiles .settings-actions .btn-primary { padding: 8px 16px; font-size: .9rem; }
@media (max-width: 640px) { .settings-tiles { grid-template-columns: 1fr; } }
/* Admin > Security */
.fw-card { max-width: 1000px; }
.fw-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px 24px; flex-wrap: wrap; }
.fw-head h2 { display: flex; align-items: center; gap: 8px; }
.fw-toggle { display: inline-flex; align-items: center; gap: 10px; padding: 10px 18px; border-radius: 999px; border: 0;
             font: inherit; font-weight: 700; color: #fff; cursor: pointer; white-space: nowrap; }
.fw-toggle .dot { width: 10px; height: 10px; border-radius: 50%; background: #fff; }
.fw-toggle.off { background: #dc2626; }
.fw-toggle.off:hover:not(:disabled) { background: #b91c1c; }
.fw-toggle.on { background: #16a34a; }
.fw-toggle.on:hover:not(:disabled) { background: #15803d; }
.fw-toggle:disabled { opacity: .55; cursor: not-allowed; }
.fw-myip { margin: 6px 0 0 !important; font-size: .9rem; }
.fw-myip .status { margin-left: 6px; }
.fw-card .alert { margin: 12px 0 0; }
.fw-card code { font-size: .85rem; }
.fw-table td, .fw-table th { vertical-align: middle; }
.fw-actions { display: flex; gap: 8px; align-items: center; }
.fw-actions form { margin: 0; }
.fw-sub { margin: 22px 0 10px; }
.fw-add { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: flex-end; }
.fw-add .field { margin: 0; min-width: 220px; }
.fw-add-buttons { display: flex; gap: 10px; flex-wrap: wrap; }
.fw-resolved { display: block; font-size: .75rem; color: var(--muted); margin-top: 2px; }
.fw-resolved.bad { color: var(--bad); }
.fw-hint { flex-basis: 100%; margin: 0 !important; }
.account-form { max-width: 460px; padding: 20px 22px; }
.account-form .field input, .account-form .field select { width: 100%; }
.admin-h1-row a.btn-primary { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; }
.fw-actions a.btn-sm { text-decoration: none; }
.account-users { max-width: 1000px; }
/* Admin > Web: a compact list, one row per setting */
.setting-list { max-width: 900px; padding: 4px 20px; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 10px 24px; flex-wrap: wrap;
               padding: 14px 0; border-bottom: 1px solid var(--border); margin: 0; }
.setting-row:last-child { border-bottom: 0; }
.setting-label { display: flex; flex-direction: column; gap: 2px; min-width: 220px; }
.setting-label > strong { display: flex; align-items: center; gap: 8px; font-size: .95rem; }
.setting-label > strong .i { color: var(--brand-accent); }
.setting-label .muted { font-size: .8rem; }
.setting-control { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.setting-control input { width: 150px; font: inherit; font-size: .9rem; color: var(--text); background: var(--field);
                         border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; }
.setting-control input.num { width: 80px; }
.setting-control .btn-sm { margin-left: 8px; }
.web-proto { color: var(--muted); font-size: .85rem; }
.web-domain { font-weight: 600; font-size: .9rem; }
/* Link-styled buttons in the admin theme keep their button text colour */
.admin-theme a.btn-primary, .admin-theme a.btn-purple, .admin-theme a.btn-primary:hover, .admin-theme a.btn-purple:hover { color: #fff; }
.admin-theme a.btn-secondary, .admin-theme a.btn-secondary:hover { color: var(--text); }
.account-head { max-width: 1000px; }
/* Admin: read-only users and disabled accounts */
/* Read-only label in the middle of the admin top bar */
.ro-pill { margin: 0 auto; display: inline-flex; align-items: center; gap: 8px; padding: 8px 16px; border-radius: 999px;
           background: #f59e0b; color: #1f1300; font-weight: 700; font-size: .9rem; letter-spacing: .02em; white-space: nowrap;
           box-shadow: 0 0 0 4px rgba(245, 158, 11, .25); }
.ro-pill .i { width: 16px; height: 16px; }
.ro-pill + .header-actions { margin-left: 0; }
/* Themed confirmation window (admin: dark; portal: light) */
.confirm-box { width: min(440px, calc(100vw - 32px)); }
.confirm-box h2 { margin: 0 0 8px; font-size: 1.1rem; }
.confirm-box p { margin: 0 0 4px; line-height: 1.5; }
.admin-theme .ro-off { opacity: .35 !important; filter: grayscale(1); pointer-events: none; cursor: not-allowed; }
.row-disabled td { opacity: .6; }
.row-disabled td.fw-actions { opacity: 1; }
.setting-control .fw-toggle { padding: 6px 14px; font-size: .85rem; }
kbd { font: inherit; font-size: .75rem; padding: 1px 6px; border: 1px solid var(--border); border-bottom-width: 2px;
      border-radius: 5px; background: var(--field); }
/* Settings pages as one list (OTM / Secure Notes / Secure Chat settings, like Admin > Web) */
.setting-list { max-width: 1000px; }
.setting-list .setting-label { flex: 1 1 360px; max-width: 560px; }
.setting-list .setting-label .muted strong { color: var(--text); }
.setting-control select { width: auto; min-width: 72px; padding: 6px 10px; font-size: .9rem; }
.setting-control label.mini { margin: 0 0 0 6px; font-size: .78rem; font-weight: 600; color: var(--muted); }
.setting-control label.mini:first-child { margin-left: 0; }
/* switches keep their own size (the text-field width above must not stretch them) */
.setting-control input.switch { width: 46px; height: 26px; padding: 0; border: 0; border-radius: 13px; margin: 0; }
.setting-group { margin: 18px 0 0 !important; padding-top: 12px; border-top: 1px solid var(--border);
                 font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.setting-group .muted { text-transform: none; letter-spacing: 0; font-weight: 400; }
.setting-note { font-size: .78rem; font-weight: 600; margin-top: 2px; }
.setting-note.ok { color: var(--ok); }
.setting-note.warn { color: var(--warn); }
.setting-actions { display: flex; justify-content: flex-end; padding: 14px 0 12px; border-top: 1px solid var(--border); }
/* Portal: create a temporary channel / room: a button next to Open, the form in a pop-up window */
.btn-create { height: 50px; padding: 0 20px; margin-left: auto; color: var(--brand-primary);
              background: color-mix(in srgb, var(--brand-primary) 8%, var(--card));
              border: 1.5px solid color-mix(in srgb, var(--brand-primary) 40%, var(--border)); }
.btn-create:hover { background: color-mix(in srgb, var(--brand-primary) 15%, var(--card)); border-color: var(--brand-primary); }
.btn-create .i { width: 14px; height: 14px; }
.create-dialog { width: min(460px, calc(100vw - 24px)); padding: 22px 24px; }
.create-dialog-head { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 16px; }
.create-dialog-head .result-badge { width: 44px; height: 44px; border-radius: 12px; font-size: 18px; }
.create-dialog-head h2 { margin: 0 0 4px; }
.create-dialog-head p { margin: 0; font-size: .85rem; line-height: 1.45; }
.create-dialog .field { margin-bottom: 12px; }
.create-dialog .field label { font-size: .92rem; margin-bottom: 4px; }
.create-dialog input, .create-dialog select { width: 100%; margin: 0; }
.create-dialog .dialog-buttons { margin-top: 18px; }
.create-dialog .alert { margin: 4px 0 0; }
.temp-tag { color: var(--warn); font-weight: 600; }
.temp-note { display: flex; align-items: center; gap: 6px; color: var(--warn); }
/* Left menu: fold to icons with the double-arrow button (desktop only; phones keep the top bar) */
.side-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 0 10px; }
.side-head .side-title { margin: 0; }
.side-toggle { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px;
               padding: 0; border-radius: 8px; border: 1px solid color-mix(in srgb, currentColor 25%, transparent);
               background: transparent; color: inherit; cursor: pointer; opacity: .75; transition: opacity .15s; }
.side-toggle:hover { opacity: 1; background: color-mix(in srgb, currentColor 10%, transparent); }
.side-toggle:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }
.side-toggle .i { width: 14px; height: 14px; transition: transform .2s; }
.sidebar .side-toggle { color: var(--tenant-header-text); }
.admin-nav .side-toggle { align-self: flex-end; margin: 0 0 6px; color: var(--muted); }
.sidebar, .admin-nav { transition: width .2s; }
@media (min-width: 901px) {
  .side-collapsed .side-toggle .i { transform: rotate(180deg); }
  /* user portal */
  .side-collapsed .sidebar { width: 66px; padding-left: 10px; padding-right: 10px; }
  .side-collapsed .side-head { justify-content: center; }
  .side-collapsed .side-head .side-title { display: none; }
  .side-collapsed .nav-item { justify-content: center; padding: 10px 0; gap: 0; }
  .side-collapsed .nav-item span { display: none; }
  /* admin portal */
  .side-collapsed .admin-nav { width: 48px; }
  .side-collapsed .admin-nav .side-toggle { align-self: center; }
  .side-collapsed .admin-nav a { justify-content: center; padding: 9px 0; gap: 0; }
  .side-collapsed .admin-nav a span, .side-collapsed .admin-nav .tag, .side-collapsed .admin-nav .chev,
  .side-collapsed .admin-nav-title, .side-collapsed .admin-nav-module > div { display: none; }
  .side-collapsed .admin-nav-module { justify-content: center; padding: 6px 0 10px; }
}
@media (max-width: 900px) { .side-toggle { display: none; } }

/* ==== Fit to the screen ===================================================================
   Desktop (720p and up): the page fills the window without scrolling. On .fill pages (OTM create/view,
   a notes channel, a chat room) header, menu and footer stay put and the main box (.fill-card) grows or
   shrinks with the window. As the window gets shorter or narrower the chrome compacts first (header,
   steps, spacing), keeping the content in focus; at 900px wide the mobile layout takes over, sized to
   fit a phone screen. */
.show-phone { display: none; }
.layout { flex: 1 1 auto; }
.main-col { min-height: 0; }
body:not(.admin-theme) { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.footer { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 2px 10px;
          margin-top: auto; padding-top: 12px; padding-bottom: 14px; font-size: .82rem; }
.footer p { margin: 0; }
.footer p + p::before { content: "·"; margin-right: 10px; color: var(--muted); }
.inline-hint { margin: 0; font-size: .8rem; text-align: right; }
.label-row { flex-wrap: wrap; }

/* .fill pages: exactly one screen high; only the main column scrolls if a window is really too small */
body.fill { height: 100vh; height: 100dvh; overflow: hidden; }
.fill .layout { flex: 1 1 0; min-height: 0; align-items: stretch; }
.fill .main-col { overflow-y: auto; }
/* (no min-height: 0 on these or the chat body: when the window is too short, the page column scrolls instead of the
   content spilling over the footer) */
.fill main.wrap, .fill #chat-app, .fill #channel-app { flex: 1 1 auto; display: flex; flex-direction: column; }
.fill .fill-card { flex: 1 1 auto; display: flex; flex-direction: column; margin-bottom: 0; }
/* OTM create: the message box takes the free height */
.fill #create-form, .fill .message-field { flex: 1 1 auto; display: flex; flex-direction: column; }
.fill .message-field textarea { flex: 1 1 0; min-height: 110px; resize: none; }
/* OTM view: the opened message is as tall as it needs, up to the free height */
.fill #revealed { flex: 0 1 auto; min-height: 0; }
.fill #revealed .message { flex: 0 1 auto; max-height: none; min-height: 90px; }
/* Notes channel: the text area takes the free height */
.fill .editor-card .pad { flex: 1 1 0; min-height: 160px; resize: none; }
/* Chat room: the message list takes the free height */
.fill .chat-body { flex: 1 1 auto; align-items: stretch; }
.fill .chat-main { display: flex; flex-direction: column; }
.fill .messages, .fill.wide .messages { flex: 1 1 0; height: auto; min-height: 150px; }
.fill .chat-people { align-self: start; max-height: 100%; overflow-y: auto; }
/* Channel / room lists: the table scrolls inside its card, its column names stay on top */
.fill .list-card .table-scroll { flex: 1 1 0; min-height: 130px; overflow: auto; }
.fill .list-card th { position: sticky; top: 0; z-index: 1; background: var(--card); }
.fill .list-card .table-tools { flex: none; }

/* OTM options: Expires | Links | Password side by side on wide screens */
@media (min-width: 641px) {
  .options { grid-template-columns: repeat(3, 1fr); gap: 0 24px; }
  .options .option-password { grid-column: auto; max-width: none; }
}
@media (min-width: 641px) and (max-width: 760px) { .options { gap: 0 14px; } }
/* Tablets / narrow windows too: the short one-line footer text */
@media (max-width: 900px) {
  .footer .hide-phone { display: none; }
  .footer .show-phone { display: inline; }
}

/* Narrower desktop windows: slimmer menu and margins */
@media (min-width: 901px) and (max-width: 1200px) {
  .sidebar { width: 190px; }
  .wrap { padding: 0 18px; }
  .header-inner { gap: 20px; padding: 0 20px; }
  .card { padding: 22px; }
  .admin-layout { gap: 20px; padding: 18px; }
  .admin-nav { width: 200px; }
}

/* Shorter windows (e.g. 1366x768, 1536x864 laptops): compact header and spacing */
@media (max-height: 820px) {
  .brand-header { padding: 12px 0; }
  .logo { max-height: 52px; }
  .header-text h1 { font-size: 1.45rem; }
  .header-text p { margin-top: 2px; font-size: .92rem; }
  .page-header { padding-top: 14px; }
  .page-header h1 { font-size: 1.3rem; }
  .steps { margin: 14px 0; }
  .steps li { padding: 8px 10px; }
  .card { padding: 20px 24px; margin: 14px 0; }
  .card h2 { margin-bottom: 12px; font-size: 1.2rem; }
  .field, .options .field, fieldset.field { margin-bottom: 14px; }
  .btn-lg { padding: 11px 20px; }
  .result-head { margin-bottom: 14px; }
  .tiles { margin: 14px 0 12px; }
  .tile { padding: 10px 12px; }
  .chat-card, .editor-card { padding: 14px 18px 16px; }
  .admin-layout { padding-top: 16px; padding-bottom: 16px; }
}
/* 720p (about 1280x600 inside the browser) and shorter */
@media (max-height: 680px) {
  .brand-header { padding: 8px 0; border-bottom-width: 3px; }
  .logo { max-height: 40px; }
  .header-text h1 { font-size: 1.2rem; }
  .header-text p { font-size: .82rem; }
  .sidebar { padding-top: 14px; }
  .page-header { padding-top: 10px; }
  .page-header h1 { font-size: 1.15rem; }
  .page-header p { margin-top: 2px; font-size: .9rem; }
  .page-note { padding: 8px 12px; }
  .open-card { padding-top: 12px; padding-bottom: 12px; }
  .search, .open-by-name .btn-primary { height: 42px; }
  .table-tools { margin-bottom: 10px; }
  .channel-table td { padding: 7px 10px; }
  .steps { margin: 10px 0; }
  .steps li { padding: 5px 8px; }
  .step-num { width: 21px; height: 21px; }
  .step-icon { height: 18px; }
  .card { padding: 16px 20px; margin: 10px 0; }
  .fit-hide { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .field, .options .field, fieldset.field { margin-bottom: 10px; }
  .field label, fieldset.field legend, .label-row { margin-bottom: 4px; }
  textarea, input[type=text], input[type=password] { padding: 8px 12px; }
  .segmented label { padding: 6px 0; }
  .btn-lg { padding: 9px 20px; font-size: 1rem; }
  .messages { padding: 10px 12px; }
  .composer textarea { min-height: 46px; }
  .composer button, .attach-btn, .auto-toggle { height: 46px; }
  .footer { padding-top: 8px; padding-bottom: 10px; font-size: .78rem; }
  .admin-layout { padding-top: 12px; padding-bottom: 12px; }
}

/* Mobile layout (tablets and phones): the menu is a bar under the header */
@media (max-width: 900px) {
  .sidebar { padding: 6px 10px; }
  .side-head { display: none; }
  .fill .layout { flex-direction: column; }
  .fill .main-col { flex: 1 1 0; min-height: 0; }
}
/* Mobile layout on a short screen (small tablets in landscape): slim header like on phones */
@media (max-width: 900px) and (max-height: 680px) {
  .brand-header { padding: 7px 0; }
  .logo { max-height: 34px; }
  .header-text p { display: none; }
  .fill .message-field textarea { min-height: 90px; }
}
/* Phones: one compact header row, steps show only the current step's name, one-line footer */
@media (max-width: 640px) {
  .hide-phone { display: none; }
  .show-phone { display: inline; }
  .brand-header { padding: 7px 0; border-bottom-width: 3px; }
  .header-inner { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 0 12px; }
  .logo { max-height: 32px; max-width: 110px; }
  .header-text { flex: 1; min-width: 0; }
  .header-text h1 { font-size: 1.08rem; }
  .header-text p { margin: 1px 0 0; font-size: .75rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .header-actions { position: static; margin-left: auto; }
  .nav-item { padding: 7px 2px; }
  .page-header { padding-top: 10px; gap: 10px; }
  .page-header h1 { font-size: 1.15rem; }
  .page-header p { font-size: .88rem; }
  /* channel / room lists */
  .page-note { gap: 8px; padding: 7px 10px; border-radius: 10px; }
  .page-note .i { width: 16px; height: 16px; }
  .page-note strong { font-size: .82rem; }
  .page-note span { font-size: .78rem; margin-top: 0; }
  .open-card { padding: 10px; }
  .open-by-name { flex-wrap: nowrap; gap: 8px; }
  .open-by-name .search { min-width: 0; }
  .search { height: 42px; padding: 0 12px; gap: 8px; }
  .search input { font-size: 1rem; }
  .open-by-name .btn-primary { height: 42px; padding: 0 14px; }
  .table-tools { margin-bottom: 8px; }
  .channel-table td { padding: 7px 8px; }
  .steps { display: flex; gap: 20px; margin: 8px 0; }
  .steps li { flex: none; padding: 3px 6px; }
  .steps li.current { flex: 1 1 auto; min-width: 0; flex-direction: row; gap: 6px; }
  .steps li:not(.current) strong { display: none; }
  .steps li strong { font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .steps li + li::before { left: -14px; }
  .step-num { width: 22px; height: 22px; }
  .card { padding: 14px; margin: 10px 0; }
  .fit-hide { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .field, .options .field, fieldset.field { margin-bottom: 10px; }
  .field label, fieldset.field legend, .label-row { margin-bottom: 4px; }
  textarea, input[type=text], input[type=password] { padding: 8px 10px; }
  .options { grid-template-columns: 1fr; gap: 0; }
  .options .option-password { max-width: none; }
  .options input[type=range] { height: 22px; margin: 0; }
  .range-ends { display: none; }
  /* Expires and Generate links: the name beside the control, one line each */
  .expires-field { display: grid; grid-template-columns: 108px minmax(0, 1fr) auto; align-items: center; gap: 0 10px; }
  .expires-field .label-row { display: contents; }
  .expires-field input[type=range] { order: 2; }
  .expires-field .pill { order: 3; }
  .links-field legend { float: left; width: 108px; margin: 0 10px 0 0; line-height: 34px; }
  .expires-field label, .links-field legend { font-size: .92rem; margin: 0; }
  .segmented label { padding: 5px 0; }
  .btn-lg { padding: 10px 16px; font-size: 1rem; }
  .fill .message-field textarea { min-height: 90px; }
  .footer { padding: 6px 12px 8px; font-size: .75rem; }
  .footer p + p::before { margin-right: 8px; }
  .tiles { gap: 8px; margin: 10px 0; }
  .tile { padding: 8px 10px; gap: 8px; }
  .tile > .i, .tile-sub { display: none; }
  .tile strong { font-size: .9rem; }
  #expires-time { display: block; font-size: .75rem; }
  .notice { margin-bottom: 12px !important; font-size: .85rem; }
  /* result / "gone" buttons side by side */
  .actions { flex-direction: row; gap: 8px; padding-top: 12px; }
  .actions button, .actions a { flex: 1 1 0; width: auto; white-space: normal; text-align: center; line-height: 1.25;
                                padding: 8px 10px; font-size: .88rem; }
  .result-badge { width: 42px; height: 42px; border-radius: 12px; font-size: 18px; }
  .result-head { gap: 12px; margin-bottom: 12px; }
  /* chat room / notes channel: compact buttons; people in one scrolling row */
  .chat-card, .editor-card { padding: 10px; }
  .chat-top { margin-bottom: 8px; }
  .chat-actions, .editor-actions { gap: 5px; }
  .chat-actions .btn-sm, .editor-actions .btn-sm { padding: 5px 8px; font-size: .8rem; gap: 5px; }
  .fill .chat-body { gap: 8px; }
  .chat-people { padding: 6px 8px; }
  .people-head { display: none; }
  .people-list { flex-wrap: nowrap; overflow-x: auto; }
  .person { flex: none; padding: 4px 8px; font-size: .82rem; }
  .fill .messages, .fill.wide .messages { min-height: 120px; }
  .history-note { margin: 4px 0 6px !important; }
  .composer { gap: 6px; }
  .editor-bar { margin-bottom: 8px; }
  .fill .editor-card .pad { min-height: 120px; }
}
/* Shorter phones: drop the header's description line (the module name stays) */
@media (max-width: 640px) and (max-height: 720px) {
  .header-text p { display: none; }
}
/* Create button / window on short screens and phones (the button shows only its + there) */
@media (max-height: 680px) {
  .btn-create { height: 42px; }
  .create-dialog { padding: 16px 20px; }
  .create-dialog-head { margin-bottom: 10px; }
  .create-dialog .field { margin-bottom: 8px; }
}
@media (max-width: 640px) {
  .btn-create { flex: none; height: 42px; width: 42px; padding: 0; margin-left: 0; font-size: 0; gap: 0; }
  .btn-create .i { width: 16px; height: 16px; }
  .create-dialog { padding: 16px; }
  .create-dialog-head .result-badge { display: none; }
  .create-dialog .field { margin-bottom: 8px; }
}
/* Mobile layout: logo + title centred; on phones the description gets its own centred line under them */
@media (max-width: 900px) {
  .header-inner { justify-content: center; flex-wrap: wrap; }
  .header-text { text-align: center; }
  .header-actions { flex-basis: 100%; justify-content: center; margin-left: 0; }
  .ro-pill { margin: 0; }
}
@media (max-width: 640px) {
  .header-inner { gap: 4px 10px; }
  .header-text { display: contents; }
  .header-text h1 { min-width: 0; }
  .header-text p { flex-basis: 100%; margin: 0; white-space: normal; text-align: center; line-height: 1.35; }
}
/* Result links on phones: the link on its own line, Copy link and Send via e-mail side by side under it */
@media (max-width: 640px) {
  .link-box button, .link-box .btn-mail { flex: 1 1 0; width: auto; padding: 10px 8px; font-size: .9rem; }
}
.create-dialog .create-hide { padding: 4px 0 0; margin: 0; gap: 14px; font-weight: 400; }
.create-dialog .create-hide strong { font-size: .92rem; }
.create-dialog .create-hide .muted { font-size: .8rem; line-height: 1.35; }
.create-dialog input.switch { width: 46px; height: 26px; flex: none; }
.create-dialog .field-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; align-items: end; }
/* "Why it's secure": header button (middle of the free header space; a shield icon at the top right on mobile),
   footer "Read more" link and the explanation window */
.header-inner { position: relative; }
.why-secure { margin: 0 0 0 auto; gap: 8px; padding: 7px 14px; border-radius: 999px; font-size: .88rem; font-weight: 600;
              color: var(--tenant-header-text); background: color-mix(in srgb, var(--tenant-header-text) 8%, transparent);
              border: 1px solid color-mix(in srgb, var(--tenant-header-text) 30%, transparent); }
.why-secure:hover { background: color-mix(in srgb, var(--tenant-header-text) 15%, transparent); }
.why-secure .i { color: var(--tenant-accent); }
/* far right of the header; the Admin portal button (when shown) sits just before it */
.header-actions:not([hidden]) + .why-secure { margin-left: 14px; }
.link-btn { display: inline; padding: 0; margin: 0 0 0 4px; border: 0; background: none; font: inherit; font-weight: 600;
            color: var(--brand-primary); text-decoration: underline; cursor: pointer; }
.security-dialog { width: min(680px, calc(100vw - 24px)); max-height: min(88vh, 88dvh); padding: 0;
                   display: none; flex-direction: column; }
.security-dialog[open] { display: flex; }
.security-head { display: flex; gap: 14px; align-items: flex-start; padding: 20px 22px 14px; border-bottom: 1px solid var(--border); }
.security-head h2 { margin: 0 0 4px; font-size: 1.2rem; }
.security-head p { margin: 0; font-size: .92rem; line-height: 1.5; }
.security-head .result-badge { width: 44px; height: 44px; border-radius: 12px; font-size: 18px; }
.security-close { margin-left: auto; flex: none; width: 34px; height: 34px; padding: 0; border-radius: 8px; font-size: 1.4rem;
                  line-height: 1; background: transparent; color: var(--muted); border: 1px solid transparent; }
.security-close:hover { background: var(--bg); color: var(--text); }
.security-body { overflow-y: auto; padding: 6px 22px 8px; line-height: 1.55; }
.security-body section { margin: 14px 0; }
.security-body h3 { display: flex; align-items: center; gap: 10px; margin: 0 0 6px; font-size: 1rem; }
.security-body p { margin: 0 0 8px; font-size: .93rem; }
.security-num { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px;
                border-radius: 50%; font-size: .8rem; background: var(--brand-primary); color: var(--brand-primary-text); }
.security-points ul { margin: 0; padding-left: 20px; font-size: .93rem; }
.security-points li { margin: 5px 0; }
.security-tech { margin: 16px 0 8px; padding: 10px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); }
.security-tech summary { cursor: pointer; font-weight: 600; font-size: .9rem; }
.security-tech p { margin: 8px 0 0; font-size: .82rem; color: var(--muted); }
.security-dialog .dialog-buttons { margin: 0; padding: 12px 22px 16px; border-top: 1px solid var(--border); }
@media (max-width: 900px) {
  .why-secure { position: absolute; top: 0; right: 12px; margin: 0; width: 36px; height: 36px; padding: 0; gap: 0; }
  .why-secure span { display: none; }
  .brand-header .header-inner { padding-right: 56px; padding-left: 56px; }
}
@media (max-width: 640px) {
  .why-secure { top: -1px; width: 32px; height: 32px; right: 8px; }
  .brand-header .header-inner { padding-right: 46px; padding-left: 46px; }
  .security-head { padding: 14px 14px 10px; gap: 10px; }
  .security-head .result-badge { display: none; }
  .security-body { padding: 4px 14px 6px; }
  .security-dialog .dialog-buttons { padding: 10px 14px 12px; }
}
/* "Why it's secure" on PC: a larger, two-line pill in the header's inverted colours (always contrasts with the header),
   with an accent-coloured ring that pulses a few times when the page opens */
@media (min-width: 901px) {
  .why-secure { gap: 11px; padding: 8px 22px 8px 16px; border-radius: 14px; border: 0; text-align: left;
                background: var(--tenant-header-text); color: var(--tenant-header-bg);
                box-shadow: 0 0 0 4px color-mix(in srgb, var(--tenant-accent) 45%, transparent), 0 6px 18px rgba(0, 0, 0, .18);
                transition: transform .15s, box-shadow .15s; animation: why-pulse 2.4s ease-in-out 3; }
  .why-secure:hover { background: var(--tenant-header-text); transform: translateY(-1px);
                      box-shadow: 0 0 0 6px color-mix(in srgb, var(--tenant-accent) 60%, transparent), 0 8px 22px rgba(0, 0, 0, .22); }
  .why-secure .i { width: 26px; height: 26px; color: inherit; }
  .why-text { display: flex; flex-direction: column; }
  .why-text strong { font-size: 1.02rem; line-height: 1.2; }
  .why-text small { font-size: .76rem; font-weight: 500; opacity: .8; line-height: 1.25; }
}
@keyframes why-pulse {
  0%, 100% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--tenant-accent) 45%, transparent), 0 6px 18px rgba(0, 0, 0, .18); }
  50% { box-shadow: 0 0 0 10px color-mix(in srgb, var(--tenant-accent) 12%, transparent), 0 6px 18px rgba(0, 0, 0, .18); }
}
@media (prefers-reduced-motion: reduce) { .why-secure { animation: none; } }
/* Wide logos (e.g. a word mark) may use a little more width */
.logo { max-width: 260px; }
@media (max-width: 640px) { .logo { max-width: 130px; } }
@media (max-width: 380px) { .logo { max-width: 110px; } }
.create-dialog .days-box { display: flex; align-items: center; gap: 10px; }
.create-dialog .days-box input { width: 110px; flex: none; font: inherit; color: var(--text); background: var(--field);
                                 border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; }
/* Mobile layout on tablets / narrow desktop windows (641-900px): the phone-style header (logo + title on one line,
   description under them), so the header doesn't take a third of the screen */
@media (min-width: 641px) and (max-width: 900px) {
  .brand-header { padding: 10px 0; }
  .header-inner { gap: 4px 14px; }
  .header-text { display: contents; }
  .logo { max-height: 44px; max-width: 200px; }
  .header-text h1 { font-size: 1.35rem; }
  .header-text p { flex-basis: 100%; margin: 0; text-align: center; font-size: .92rem; line-height: 1.35; }
}
/* Portal lists: "Expires in" (time left, with "temporary" / "if not used" under it) */
.expires-cell { white-space: nowrap; }
.expires-cell .until { font-weight: 600; font-variant-numeric: tabular-nums; }
/* Admin > Web: "Company logo opens" */
.setting-control.logo-link-control input[type=url] { width: 240px; }
.setting-control.logo-link-control input[type=url]:disabled { opacity: .4; cursor: not-allowed; }
/* "Hide from list" turned off by the company admin: greyed out */
#hide-btn.is-locked, #hide-btn:disabled { opacity: .45; cursor: not-allowed; filter: grayscale(1); }
.is-locked .switch, .switch-row.is-locked { cursor: not-allowed; }
.is-locked .switch:disabled { opacity: .45; }
.create-hide.is-locked strong { color: var(--muted); }
/* Admin: a setting that depends on another one, greyed out while that one blocks it */
.setting-row.is-locked .setting-label { opacity: .5; }
.setting-row.is-locked .switch:disabled { opacity: .4; cursor: not-allowed; }
.state-btn:disabled { opacity: .45; cursor: not-allowed; filter: grayscale(1); }
/* OTM create: the "no secrets in the title" warning right next to the Title label, in red-orange */
.label-row.title-row { justify-content: flex-start; gap: 4px 14px; }
.title-warning { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px;
                 font-size: .82rem; line-height: 1.35; color: #c2410c; background: #fff1e6;
                 border: 1px solid color-mix(in srgb, #ea580c 35%, transparent); }
.title-warning .i { flex: none; width: 14px; height: 14px; color: #ea580c; }
.title-warning strong { font-weight: 700; }
@media (max-width: 640px) { .title-warning { font-size: .75rem; padding: 2px 8px; } }
@media (max-height: 680px) { .title-warning { padding: 0 9px; line-height: 1.3; } }
@media (min-width: 641px) and (max-height: 680px) { .fill .message-field textarea { min-height: 100px; } }
/* Narrow phones (360px): the footer stays on one line */
@media (max-width: 380px) { .footer { font-size: .7rem; gap: 2px 6px; } .footer p + p::before { margin-right: 6px; } }
@media (max-width: 640px) { .title-warning { padding: 0 8px; line-height: 1.3; } }
/* 360px phones: logo + title still on one line */
@media (max-width: 380px) { .logo { max-width: 100px; } .header-text h1 { font-size: 1rem; } }
@media (max-width: 640px) { .label-row.title-row { margin-bottom: 2px; } }
/* OTM create: "(optional)" next to Title and Password in orange */
.optional { color: #ea580c; font-weight: 600; }
/* Admin: "Keep forever" under a temporary channel/room's delete date */
.keep-form { margin: 4px 0 2px; }
.btn-keep { gap: 6px; padding: 4px 10px; font-size: .8rem; color: var(--ok); background: var(--ok-bg);
            border: 1px solid color-mix(in srgb, var(--ok) 40%, transparent); }
.btn-keep:hover:not(:disabled) { border-color: var(--ok); }
.btn-keep .i { width: 13px; height: 13px; }
/* Hidden "IP info" window (Alt+I then Alt+P on the OTM start page) */
.ipinfo-dialog { width: min(500px, calc(100vw - 24px)); padding: 0; }
.ipinfo-body { padding: 12px 22px 8px; }
.ipinfo-status { margin: 8px 0 14px !important; color: var(--muted); }
.ipinfo-status.error { color: var(--bad); }
.ipinfo-list { margin: 0; }
.ipinfo-list > div { display: grid; grid-template-columns: 100px 1fr; gap: 12px; align-items: baseline;
                     padding: 9px 0; border-bottom: 1px solid var(--border); }
.ipinfo-list > div:last-child { border-bottom: 0; }
.ipinfo-list dt { font-size: .85rem; color: var(--muted); }
.ipinfo-list dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.ipinfo-ip { font: 600 1.2rem/1.3 ui-monospace, "Cascadia Mono", Consolas, monospace; }
.ipinfo-ver:not(:empty) { margin-left: 8px; padding: 1px 8px; border: 1px solid var(--border); border-radius: 999px;
                          background: var(--bg); color: var(--muted); font-size: .72rem; vertical-align: middle; }
.ipinfo-note { margin: 10px 0 4px !important; font-size: .78rem; color: var(--muted); }
.ipinfo-dialog .dialog-buttons { margin: 0; padding: 12px 22px 16px; border-top: 1px solid var(--border); }
.ipinfo-dialog .dialog-buttons .i { width: 14px; height: 14px; margin-right: 6px; }
@media (max-width: 640px) {
  .ipinfo-body { padding: 8px 14px 6px; }
  .ipinfo-list > div { grid-template-columns: 84px 1fr; gap: 8px; }
  .ipinfo-dialog .dialog-buttons { padding: 10px 14px 12px; }
}
/* Phones: once revealed, "IP info" is a small icon-only 4th tab so the three module names keep their room */
@media (max-width: 640px) {
  .side-nav.mods-1:has(#ip-nav:not([hidden])) { grid-template-columns: minmax(0, 1fr) 40px; }
  .side-nav.mods-2:has(#ip-nav:not([hidden])) { grid-template-columns: repeat(2, minmax(0, 1fr)) 40px; }
  .side-nav.mods-3:has(#ip-nav:not([hidden])) { grid-template-columns: repeat(3, minmax(0, 1fr)) 40px; }
  .side-nav.mods-4:has(#ip-nav:not([hidden])) { grid-template-columns: repeat(4, minmax(0, 1fr)) 36px; }
  #ip-nav { padding-left: 0; padding-right: 0; gap: 0; }
  #ip-nav span { display: none; }
}
/* Password Generator (pwgen.html) */
.pwgen-top { display: flex; align-items: center; gap: 8px 18px; flex-wrap: wrap; margin-bottom: 14px; }
.pwgen-mode { margin: 0; flex: 0 1 420px; }
.pwgen-mode-help { margin: 0; font-size: .9rem; flex: 1 1 240px; }
.pwgen-output { display: flex; flex-direction: column; padding: 12px;
                border: 1px solid var(--border); border-radius: 12px; background: var(--bg); }
.pwgen-list { display: flex; flex-direction: column; gap: 8px; }
.pwgen-list.many { max-height: min(38vh, 420px); overflow-y: auto; }   /* several: the list scrolls, not the page */
.pw-empty { margin: 6px 4px; }
.pwgen-list.many { justify-content: flex-start; }
.pw-row { display: flex; align-items: center; gap: 10px; padding: 6px 6px 6px 14px; border-radius: 10px;
          background: var(--card); border: 1px solid var(--border); }
.pw-value { flex: 1; min-width: 0; overflow-wrap: anywhere; user-select: all;
            font: 600 1.35rem/1.35 ui-monospace, "Cascadia Mono", Consolas, monospace; letter-spacing: .02em; }
.pwgen-list.many .pw-value, .pw-pair .pw-value { font-size: 1.02rem; }
.pw-tag { flex: none; min-width: 58px; font-size: .75rem; font-weight: 700; text-transform: uppercase; color: var(--muted); }
.pw-pair { display: flex; flex-direction: column; gap: 6px; }
.pw-pair + .pw-pair { padding-top: 8px; border-top: 1px dashed var(--border); }
.pw-copy { flex: none; padding: 8px 10px; }
.pw-copy.copied, #pw-copy-all.copied { color: var(--ok); border-color: var(--ok); }
.pw-strength { display: flex; align-items: center; gap: 12px; margin-top: 12px; font-size: .9rem; }
.pw-meter { flex: 0 0 140px; height: 8px; border-radius: 4px; background: var(--border); overflow: hidden; }
.pw-meter i { display: block; height: 100%; width: 0; border-radius: 4px; transition: width .25s, background .25s; }
.pw-strength.weak .pw-meter i { background: var(--bad); }
.pw-strength.fair .pw-meter i { background: #e8a317; }
.pw-strength.strong .pw-meter i, .pw-strength.vstrong .pw-meter i { background: var(--ok); }
.pw-strength.weak strong { color: var(--bad); }
.pw-strength.strong strong, .pw-strength.vstrong strong { color: var(--ok); }
.pwgen-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0 0; }
.pwgen-actions .i { width: 15px; height: 15px; }
.pwgen-opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 28px; align-items: start;
              padding-bottom: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.pwgen-opts[hidden] { display: none; }
.pwgen-opts.pwgen-readable { display: block; }
.pwgen-opts.pwgen-readable[hidden] { display: none; }
.pwgen-opts .field { margin-bottom: 14px; }
.pwgen-wg p { grid-column: 1 / -1; margin: 0 0 14px; font-size: .92rem; line-height: 1.5; }
.pw-switch { padding: 6px 0; border-bottom: 0; margin: 0 0 14px !important; align-self: center; }
.pw-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.pw-chip { position: relative; margin: 0 !important; }
.pw-chip input { position: absolute; opacity: 0; pointer-events: none; }
.pw-chip span { display: inline-block; min-width: 60px; padding: 8px 12px; text-align: center; border-radius: 8px;
                border: 1px solid var(--border); background: var(--field); color: var(--muted); cursor: pointer;
                font: 600 .9rem ui-monospace, "Cascadia Mono", Consolas, monospace; }
.pw-chip input:checked + span { background: var(--brand-primary); border-color: var(--brand-primary); color: var(--brand-primary-text); }
.pw-chip input:disabled + span { cursor: not-allowed; opacity: .75; }
.pw-chip input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 1px; }
/* "How many" sits at the end of the buttons row, the privacy note at the end of the strength line */
.pwgen-count { display: flex; align-items: center; gap: 10px; margin: 0 0 0 auto; padding: 0; border: 0; min-width: 0; }
.pwgen-count legend { float: left; padding: 0; font-weight: 600; font-size: .9rem; white-space: nowrap; }
.pwgen-count .segmented { width: 200px; }
.pwgen-count .segmented label { padding: 7px 0; }
.pwgen-note { display: inline-flex; align-items: center; gap: 6px; margin: 0 0 0 auto; font-size: .82rem; }
/* several passwords: tighter rows so three or more fit */
.pwgen-list.many { gap: 5px; }
.pwgen-list.many .pw-row { padding: 2px 4px 2px 12px; }
.pwgen-list.many .pw-copy { padding: 4px 8px; }
.pwgen-note .i { color: var(--ok); }
@media (max-height: 820px) and (min-width: 901px) {
  .pwgen-top { margin-bottom: 10px; }
  .pwgen-opts { padding-bottom: 0; margin-bottom: 10px; }
  .pwgen-opts .field, .pw-switch { margin-bottom: 8px !important; }
}
@media (max-width: 640px) {
  .pwgen-mode { flex-basis: 100%; }
  .pwgen-actions { flex-wrap: wrap !important; }
  .pwgen-count { flex: 1 1 100%; margin: 2px 0 0; }
  .pwgen-count .segmented { flex: 1; width: auto; }
  .pwgen-mode-help { display: none; }
  .pwgen-actions { gap: 8px; margin: 10px 0 4px; flex-wrap: nowrap; }
  .pwgen-actions button { flex: 1 1 0; min-width: 0; padding-left: 8px; padding-right: 8px; }
  .pwgen-top { margin-bottom: 10px; }
  .pw-strength { margin-top: 8px; }
  .pwgen-opts { padding-bottom: 2px; margin-bottom: 10px; }
  .pwgen-opts .field, .pw-switch { margin-bottom: 10px !important; }
  .pw-switch .muted { display: none; }
  .pwgen-opts { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
  .pwgen-opts[data-for="random"] > * { grid-column: 1 / -1; }
  .pwgen-opts .segmented label { padding: 7px 0; }
  .pwgen-note { display: none; }   /* the header line under the title already says it */
  .pwgen-list:not(.many) .pw-value { font-size: 1.05rem; }
  .pw-meter { flex-basis: 80px; }
  .pwgen-output { padding: 8px; }
}
/* Readable structure builder (pwgen-structure.js): part buttons with their option underneath, then the structure */
.pw-parts { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 10px; }
.pw-part { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.pw-part select, .pw-part input[type=text] { width: 100%; padding: 6px 8px; font-size: .9rem; }
.pw-part input[type=text] { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; text-align: center; }
.pw-part-note { font-size: .8rem; text-align: center; padding: 6px 0; }
.pw-mini { display: flex; align-items: center; gap: 6px; }
.pw-mini input[type=range] { flex: 1; min-width: 0; margin: 0; }
.pw-mini .pill { min-width: 26px; text-align: center; }
/* Each part has its own colour, the same on its "+" button and in the structure (same for every company) */
.part-word { --part: #0891d1; }      /* light blue */
.part-numbers { --part: #16a34a; }   /* green */
.part-symbols { --part: #ea580c; }   /* orange */
.part-sep { --part: #64748b; }       /* grey */
.part-colour { --part: #9333ea; }    /* purple */
.part-animal { --part: #db2777; }    /* pink */
.part-custom { --part: #0d9488; }    /* teal */
.part-food { --part: #ca8a04; }      /* mustard */
.part-place { --part: #4f46e5; }     /* indigo */
.part-myth { --part: #92400e; }      /* brown */
.part-space { --part: #1e3a8a; }     /* navy */
.part-vehicle { --part: #b91c1c; }   /* dark red */
.part-movie { --part: #65a30d; }     /* lime */
.pw-add { gap: 6px; padding: 8px 6px; font-size: .9rem; color: var(--part, var(--text));
          background: color-mix(in srgb, var(--part, transparent) 10%, var(--card));
          border: 1.5px solid color-mix(in srgb, var(--part, var(--border)) 55%, transparent); }
.pw-add:hover:not(:disabled) { background: color-mix(in srgb, var(--part) 18%, var(--card)); border-color: var(--part); }
.pw-add .i { width: 11px; height: 11px; }
.pw-structure-head { display: flex; align-items: baseline; gap: 10px; margin: 12px 0 6px; font-size: .9rem; }
.pw-structure-head .muted { font-size: .82rem; }
.pw-structure-head .link-btn { margin-left: auto; font-size: .85rem; }
.pw-structure { display: flex; flex-wrap: wrap; gap: 6px; min-height: 44px; padding: 6px; border: 1px solid var(--border);
                border-radius: 10px; background: var(--bg); }
.pw-structure-empty { margin: 6px 0 0; font-size: .85rem; }
.pw-chip-part { padding: 6px 12px; font-size: .88rem; border-radius: 999px; cursor: grab; touch-action: none;
                user-select: none; color: #fff; background: var(--part); border: 1px solid transparent; }
.pw-chip-part:hover { filter: brightness(1.1); text-decoration: line-through; }
.pw-structure.is-dragging .pw-chip-part:hover { text-decoration: none; }
.pw-chip-part.dragging { cursor: grabbing; opacity: .55; outline: 2px dashed var(--brand-primary); outline-offset: 2px; }
/* admin: parts in one row, the builder under the label */
.setting-row-wide { flex-direction: column; align-items: stretch; }
.setting-row-wide .setting-label { flex: none; }
.pw-builder-admin { width: 100%; }
.pw-parts-admin { grid-template-columns: repeat(7, minmax(0, 1fr)); }
@media (max-width: 1100px) and (min-width: 641px) {
  .pw-parts { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .pw-parts { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px 6px; }
  .pw-add { padding: 6px 2px; font-size: .8rem; gap: 0; }
  .pw-add .i { display: none; }
  .pw-part select, .pw-part input[type=text] { padding: 5px 2px; font-size: .8rem; }
  .pw-part-note { font-size: .72rem; padding: 4px 0; }
  .pw-structure-head { margin-top: 10px; }
  .pw-chip-part { padding: 5px 10px; font-size: .82rem; }
}
/* Readable tab: the five parts it mixes (shown, not clickable) */
.pw-chip-static { cursor: default; touch-action: auto; }
.pw-chip-static:hover { filter: none; text-decoration: none; }
.pwgen-mode { flex-basis: 520px; }
@media (max-width: 640px) {
  .pwgen-mode .segmented label { font-size: .85rem; }
}
/* Custom: Random / Clear / Default next to "Structure" */
.pw-structure-btns { margin-left: auto; display: inline-flex; align-items: center; gap: 12px; }
.pw-structure-head .pw-structure-btns .link-btn { margin: 0; }
.pw-random-btn { gap: 5px; padding: 3px 10px; font-size: .8rem; border-radius: 999px; color: var(--muted);
                 background: var(--card); border: 1px solid var(--border); }
.pw-random-btn .i { width: 11px; height: 11px; }
.pw-random-btn.on { color: var(--brand-primary-text); background: var(--brand-primary); border-color: var(--brand-primary); }
@media (max-width: 640px) {
  .pw-structure-head { flex-wrap: wrap; align-items: center; }
  .pw-structure-head > .show-phone { display: none; }
}
/* Custom: the read-only Auto line (same look as the structure) and the two result boxes */
.pw-auto-line { display: flex; flex-wrap: wrap; gap: 6px; min-height: 44px; padding: 6px; border: 1px dashed var(--border);
                border-radius: 10px; background: var(--bg); }
.pw-group { display: flex; flex-direction: column; gap: 6px; padding: 8px; border: 1px solid var(--border); border-radius: 10px;
            background: var(--card); }
.pw-group + .pw-group { margin-top: 2px; }
.pw-group-title { margin: 0 0 2px 4px; font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
                  color: var(--muted); }
.pwgen-list.grouped .pw-row { background: var(--bg); }
/* Custom on phones: the Auto / Your own switch, and only the chosen one is shown */
.pw-view-switch { display: none; }
@media (max-width: 640px) {
  .pw-view-switch { display: grid; margin-bottom: 10px; }
  #pwgen[data-view="auto"] .pw-own-only, #pwgen[data-view="own"] .pw-auto-only { display: none !important; }
}
/* phones: Copy / Send as OTM without their icons so the three buttons never run into each other */
@media (max-width: 640px) {
  #pw-copy-all .i, #pw-send .i { display: none; }
  .pwgen-actions button { overflow: hidden; }
}
/* Secure Notes / Secure Chat: the short introduction above "Open channel / room" */
.module-intro { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 14px 26px; padding: 14px 18px; margin-bottom: 14px;
                font-size: .88rem; line-height: 1.5; }
.module-intro p { margin: 0; }
.module-intro h3 { margin: 0 0 4px; font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.module-intro ul { margin: 0; padding-left: 18px; }
.module-intro li { margin: 1px 0; }
.intro-what { display: flex; gap: 12px; align-items: flex-start; }
.intro-icon { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px;
              border-radius: 10px; color: var(--brand-primary); background: color-mix(in srgb, var(--brand-primary) 12%, var(--card)); }
.intro-icon .i { width: 17px; height: 17px; }
.intro-col + .intro-col { border-left: 1px solid var(--border); padding-left: 22px; }
@media (max-width: 1100px) {
  .module-intro { grid-template-columns: 1fr 1fr; }
  .intro-what { grid-column: 1 / -1; }
  .intro-good { border-left: 0 !important; padding-left: 0 !important; }
}
@media (max-height: 760px) and (min-width: 901px) { .intro-how { display: none; } .module-intro { grid-template-columns: 1.4fr 1fr; } }
@media (max-width: 640px) {
  .module-intro { display: block; padding: 10px 12px; font-size: .84rem; margin-bottom: 10px; }
  .intro-good, .intro-how { display: none; }
  .intro-icon { width: 30px; height: 30px; }
}
/* Custom: an empty "Your own" says so inside the box, big enough to notice */
#w-builder .pw-structure:empty { align-items: center; }
#w-builder .pw-structure:empty::before { content: attr(data-empty); padding: 4px 10px; font-weight: 700; font-size: 1.15rem;
                                         color: #16a34a; }
#w-builder .pw-structure-empty { display: none !important; }
.pw-structure-head.pw-auto-only { margin-top: 14px; }
@media (max-width: 640px) {
  #w-builder .pw-structure:empty::before { font-size: 1rem; }
  .pw-structure-head.pw-auto-only { margin-top: 10px; }
}
/* Phones and small tablets (mobile layout): pages scroll like a normal web page (header and menu scroll away, the
   browser bar can hide) instead of only the middle scrolling inside a box. The chat room and a notes channel
   (.app-like) stay locked to the screen like an app. Text boxes use 16px so iPhones don't zoom in when tapped. */
@media (max-width: 900px) {
  body.fill:not(.app-like) { height: auto; min-height: 100vh; min-height: 100dvh; overflow: visible; }
  body.fill:not(.app-like) .layout { flex: 1 0 auto; }
  body.fill:not(.app-like) .main-col { overflow: visible; }
  input:not([type=radio]):not([type=checkbox]):not([type=range]), textarea, select { font-size: 16px !important; }
  .footer .link-btn { padding: 6px 2px; }
}
/* Admin > Secure Notes > Channels > Edit: attached files */
.files-settings { margin: 4px 0 8px; padding-top: 8px; border-top: 1px solid var(--border); }
.files-settings .switch-row { border-bottom: 0; padding: 6px 0 10px; }
.files-limits { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.files-limits.is-off { display: none; }   /* the limits only show while files are switched on */
.files-tag { display: block; }
/* Secure Notes channel: attached files (under the notepad) */
.note-files { flex: none; margin-top: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); }
.note-files-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.note-files-head strong { display: inline-flex; align-items: center; gap: 6px; }
.note-files-head .muted { font-size: .85rem; }
.note-files-head .btn-sm { margin-left: auto; }
.note-files-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.note-files-list:empty { display: none; }
.note-file { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 8px; background: var(--card);
             border: 1px solid var(--border); }
.note-file > .i { flex: none; color: var(--muted); }
.note-file-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.note-file-size { flex: none; font-size: .82rem; }
.files-empty { margin: 6px 0 0; font-size: .85rem; }
@media (max-width: 640px) {
  .note-file { flex-wrap: wrap; }
  .note-file-name { flex-basis: calc(100% - 40px); }
  .note-file-size { margin-right: auto; }
}
/* the switch keeps its normal size (dialog inputs are otherwise full width), text on the left, switch on the right */
.files-settings .switch-row { display: flex; align-items: center; gap: 16px; }
.files-settings .switch { width: 46px; flex: none; }
