:root {
  color-scheme: light;
  --bg: #ebedf1;
  --mica-tint: rgba(248, 249, 251, 0.84);
  --window: rgba(255, 255, 255, 0.72);
  --window-strong: rgba(255, 255, 255, 0.9);
  --panel: rgba(255, 255, 255, 0.64);
  --panel-strong: rgba(255, 255, 255, 0.82);
  --line: rgba(14, 23, 38, 0.08);
  --line-strong: rgba(14, 23, 38, 0.14);
  --text: #111827;
  --muted: #5d6777;
  --accent: #0a64d6;
  --accent-strong: #084fb0;
  --accent-soft: rgba(10, 100, 214, 0.12);
  --warn-soft: rgba(216, 86, 49, 0.14);
  --radius-window: 28px;
  --radius-panel: 20px;
  --radius-control: 14px;
  --shadow-window: 0 28px 60px rgba(33, 41, 52, 0.16);
  --shadow-panel: inset 0 1px 0 rgba(255, 255, 255, 0.6);
  /* Surface backgrounds — override in dark mode */
  --bg-gradient: radial-gradient(circle at 18% 18%, rgba(12, 100, 214, 0.16), transparent 24%), radial-gradient(circle at 78% 12%, rgba(0, 120, 212, 0.1), transparent 22%), linear-gradient(180deg, #f4f6f9 0%, #e9edf3 42%, #dde3ec 100%);
  --mica-overlay: linear-gradient(135deg, rgba(255, 255, 255, 0.38), transparent 34%), linear-gradient(315deg, rgba(255, 255, 255, 0.22), transparent 32%);
  --window-bg-end: rgba(238, 241, 246, 0.72);
  --surface-1: rgba(255, 255, 255, 0.62);
  --surface-2: rgba(255, 255, 255, 0.58);
  --surface-3: rgba(255, 255, 255, 0.72);
  --surface-4: rgba(255, 255, 255, 0.42);
  --surface-5: rgba(249, 250, 252, 0.88);
  --surface-hover: rgba(255, 255, 255, 0.94);
  --surface-input-focus: rgba(255, 255, 255, 0.96);
  --surface-toolbar: rgba(255, 255, 255, 0.7);
  --surface-tabs: rgba(239, 242, 247, 0.9);
  --surface-tab-active: rgba(255, 255, 255, 0.9);
  --surface-device: rgba(255, 255, 255, 0.55);
  --surface-code-card: linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(246, 248, 252, 0.84));
  --surface-preview: rgba(255, 255, 255, 0.98);
  --surface-qr: rgba(255, 255, 255, 0.88);
  --surface-pinned: linear-gradient(180deg, rgba(244, 249, 255, 0.96), rgba(255, 255, 255, 0.72));
  --flash-bg: rgba(220, 238, 255, 0.9);
  --hover-overlay: rgba(0, 0, 0, 0.07);
  --warn-text: #8a5d28;
  --badge-idle-bg: rgba(81, 96, 113, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: "Segoe UI", "Noto Sans SC", sans-serif;
  color: var(--text);
  background: var(--bg-gradient);
  overflow-x: hidden;
}

button,
input,
textarea,
[contenteditable] {
  font: inherit;
}

h1,
h2,
h3,
p,
dl,
dd,
dt {
  margin: 0;
}

.mica-backdrop {
  position: fixed;
  inset: 0;
  background: var(--mica-overlay);
  pointer-events: none;
}

.window-shell {
  width: min(1380px, calc(100vw - 28px));
  min-height: calc(100vh - 28px);
  margin: 14px auto;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.66);
  border-radius: var(--radius-window);
  background: linear-gradient(180deg, var(--mica-tint), var(--window-bg-end));
  box-shadow: var(--shadow-window);
  backdrop-filter: blur(24px) saturate(120%);
}

.window-titlebar {
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 4px 10px 16px;
}

.titlebar-app,
.titlebar-status,
.section-heading,
.inline-field,
.button-row {
  display: flex;
  align-items: center;
}

.history-item {
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.history-body {
  min-width: 0;
  width: 100%;
  order: 1;
}

.history-item-actions {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  order: 0;
  padding-left: 0;
  margin-bottom: 5px;
}

.titlebar-app {
  gap: 14px;
}

.app-icon {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  background: linear-gradient(180deg, #2ca0ff, #0a64d6);
  box-shadow: 0 6px 18px rgba(10, 100, 214, 0.34);
}

.caption-label,
.section-label,
.section-note,
.code-caption,
.field-label,
.history-meta,
.timeline-meta {
  color: var(--muted);
}

.caption-label,
.section-label,
.code-caption,
.field-label {
  font-size: 12px;
  font-weight: 600;
}

.window-titlebar h1 {
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.titlebar-status {
  gap: 10px;
}

.caption-button,
.primary-button,
.secondary-button,
.ghost-button,
.tab-button {
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color 140ms ease, border-color 140ms ease, transform 140ms ease, box-shadow 140ms ease;
}

.caption-button,
.primary-button,
.secondary-button,
.ghost-button {
  min-height: 36px;
  padding: 0 14px;
  border-radius: 10px;
  font-weight: 600;
}

.caption-button,
.ghost-button {
  color: var(--text);
  background: var(--surface-4);
  border-color: var(--line);
}

.primary-button {
  color: #fff;
  background: linear-gradient(180deg, #1674e6, var(--accent));
  border-color: rgba(7, 62, 140, 0.4);
  box-shadow: 0 10px 24px rgba(10, 100, 214, 0.22);
}

.secondary-button {
  color: var(--text);
  background: var(--surface-toolbar);
  border-color: var(--line);
}

.caption-button:hover,
.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover,
.tab-button:hover {
  transform: translateY(-1px);
}

.window-content {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 14px;
}

.sidebar-column,
.main-column {
  min-width: 0;
  display: grid;
  gap: 14px;
}

.sidebar-panel,
.workspace-panel {
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: var(--radius-panel);
  background: linear-gradient(180deg, var(--panel-strong), var(--panel));
  box-shadow: var(--shadow-panel);
}

.sidebar-panel {
  padding: 16px;
}

.workspace-panel {
  padding: 18px;
}

.overview-panel {
  display: grid;
  gap: 14px;
  align-content: start;
}

.status-card,
.capability-strip {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface-2);
}

.status-card {
  padding: 14px;
}

.status-card p:last-of-type {
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
}

.status-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  color: var(--muted);
}

.status-meta-row strong {
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
}

.status-device-block {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.status-device-block .field-label {
  margin-bottom: 8px;
}

.device-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 6px;
}

.device-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 11px;
  border-radius: 11px;
  background: var(--surface-device);
  border: 1px solid var(--line-strong);
  font-size: 12px;
}

.device-name {
  color: var(--text);
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.device-state {
  color: var(--muted);
  flex-shrink: 0;
}

.device-item.is-local {
  border-color: rgba(16, 100, 200, 0.25);
  background: rgba(16, 100, 200, 0.08);
}

.device-item.is-online .device-state {
  color: var(--accent-strong);
}

.device-item.is-pending .device-state {
  color: var(--warn-text);
}

.device-item.is-empty {
  justify-content: center;
  color: var(--muted);
  border-style: dashed;
}

.session-code-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface-code-card);
  padding: 14px;
  display: grid;
  gap: 8px;
}

.session-join-label {
  display: block;
  margin-bottom: 4px;
}

.session-join-field {
  margin-bottom: 6px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.session-join-field input {
  min-width: 0;
}

.session-join-field .secondary-button {
  min-width: 68px;
  padding-inline: 12px;
}

.session-code-card strong {
  display: block;
  margin-top: 2px;
  line-height: 1;
  font-size: 32px;
  font-weight: 700;
  letter-spacing: 0.14em;
}

.button-stack {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.button-stack .primary-button {
  grid-column: 1 / -1;
}

.compact-field {
  align-items: stretch;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.status-idle {
  color: var(--muted);
  background: var(--badge-idle-bg);
}

.status-ready {
  color: var(--accent-strong);
  
}

.status-warn {
  color: #a44a2d;
  background: var(--warn-soft);
}

#transportSummary.status-idle {
  color: var(--muted);
}

#transportSummary.status-ready {
  color: var(--accent-strong);
}

#transportSummary.status-warn {
  color: #a44a2d;
}

.section-heading {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.section-heading h2 {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.section-note {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.qr-block {
  margin-top: 8px;
  width: 100%;
  min-height: 132px;
  border-radius: 16px;
  border: 1px solid rgba(10, 100, 214, 0.18);
  background:
    linear-gradient(90deg, rgba(10, 100, 214, 0.08) 25%, transparent 25%) 0 0 / 16px 16px,
    linear-gradient(rgba(17, 24, 39, 0.05) 25%, transparent 25%) 0 0 / 16px 16px,
    var(--surface-qr);
  display: grid;
  place-items: center;
  text-align: center;
  padding: 8px;
  white-space: pre-line;
  font-weight: 700;
  color: var(--text);
}

.qr-image {
  width: 116px;
  height: 116px;
  border-radius: 10px;
  background: #fff;
  object-fit: contain;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
}

.history-list,
.file-list {
  display: grid;
  gap: 6px;
}

.timeline-item,
.history-item,
.file-list li,
.preview-card,
.dropzone {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface-1);
}

.timeline-item,
.file-list li {
  padding: 12px 14px;
}

.history-item {
  padding: 8px 12px;
}

.timeline-item p,
.history-type {
  font-size: 14px;
  font-weight: 600;
}

.history-type {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.history-meta,
.timeline-item span {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  line-height: 1.4;
}

.clipboard-panel {
  min-height: 400px;
}

.capability-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  margin-bottom: 14px;
}

.capability-strip .field-label {
  margin-bottom: 0;
  flex: 0 0 auto;
}

.capability-strip p {
  font-size: 13px;
  line-height: 1.45;
  color: var(--muted);
}

.support-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}

.support-item + .support-item::before {
  content: "/";
  margin: 0 4px;
  color: var(--line-strong);
}

.support-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.support-item.is-ok .support-dot {
  background: #22c55e;
  box-shadow: 0 0 4px rgba(34, 197, 94, 0.5);
}

.support-item.is-bad .support-dot {
  background: #ef4444;
  box-shadow: 0 0 4px rgba(239, 68, 68, 0.5);
}

.composer-tabs {
  display: inline-flex;
  gap: 8px;
  margin-bottom: 14px;
  padding: 4px;
  border-radius: 14px;
  background: var(--surface-tabs);
}

.tab-button {
  min-height: 34px;
  padding: 0 14px;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
}

.tab-button.is-active {
  color: var(--text);
  background: var(--surface-tab-active);
  border-color: var(--line);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.history-filter-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  padding-bottom: 2px;
  overflow-x: auto;
}

.history-search-row {
  position: relative;
  margin-bottom: 10px;
}

.history-search-input {
  width: 100%;
  box-sizing: border-box;
  height: 32px;
  padding: 0 34px 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-3);
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.history-search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(10, 100, 214, 0.14);
}

.history-search-clear {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: color 120ms ease, background 120ms ease;
}

.history-search-clear:hover {
  color: var(--text);
  background: var(--hover-overlay);
}

.history-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px 0 4px;
}

.history-page-btn {
  height: 28px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease, opacity 120ms ease;
}

.history-page-btn:disabled {
  opacity: 0.38;
  cursor: default;
}

.history-page-btn:not(:disabled):hover {
  background: var(--accent-soft);
  color: var(--accent-strong);
  border-color: rgba(10, 100, 214, 0.24);
}

.history-page-info {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.history-filter-button {
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease;
}

.history-filter-button.is-active {
  color: var(--accent-strong);
  background: var(--accent-soft);
  border-color: rgba(10, 100, 214, 0.24);
}

.tab-panel {
  display: none;
}

.tab-panel.is-active {
  display: block;
}

.field-label {
  display: block;
  margin-bottom: 8px;
}

input[type="text"],
.richtext-editor,
input[type="file"] {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-control);
  background: var(--surface-5);
  color: var(--text);
}

input[type="text"],
input[type="file"] {
  min-height: 40px;
  padding: 0 13px;
}

.richtext-editor {
  min-height: 230px;
  resize: vertical;
  overflow: auto;
  padding: 12px 14px;
  line-height: 1.55;
  outline: none;
  border-radius: 0 0 var(--radius-control) var(--radius-control);
  word-break: break-word;
  white-space: pre-wrap;
}

.richtext-editor:empty::before {
  content: attr(data-placeholder);
  color: var(--muted);
  pointer-events: none;
}

.richtext-editor img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
}

.richtext-editor:focus {
  border-color: var(--accent);
  background: var(--surface-input-focus);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.richtext-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  row-gap: 6px;
  padding: 5px 8px;
  border: 1px solid var(--line-strong);
  border-bottom: none;
  border-radius: var(--radius-control) var(--radius-control) 0 0;
  background: var(--surface-toolbar);
}

.richtext-tool {
  min-height: 26px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 120ms, color 120ms;
  white-space: nowrap;
}

.richtext-tool.is-wide {
  padding: 0 10px;
}

.richtext-tool:hover {
  background: rgba(10, 100, 214, 0.09);
  color: var(--accent);
}

.richtext-tool.is-active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: rgba(10, 100, 214, 0.18);
}

.richtext-sep {
  width: 1px;
  height: 16px;
  margin: 0 4px;
  background: var(--line-strong);
}

@media (max-width: 720px) {
  .richtext-toolbar {
    gap: 3px;
    padding: 6px;
  }

  .richtext-tool {
    min-height: 30px;
    font-size: 11px;
    padding: 0 7px;
  }
}

.inline-field,
.button-row {
  gap: 10px;
}

.button-row {
  margin-top: 12px;
}

.sync-toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  user-select: none;
  cursor: pointer;
}

.sync-toggle-label input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.sync-toggle-label .toggle-track {
  position: relative;
  display: inline-block;
  flex-shrink: 0;
  width: 40px;
  height: 22px;
  border-radius: 11px;
  background: rgba(100, 116, 134, 0.35);
  border: 1.5px solid rgba(100, 116, 134, 0.25);
  transition: background 180ms ease, border-color 180ms ease;
}

.sync-toggle-label .toggle-track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.22);
  transition: transform 180ms ease;
}

.sync-toggle-label input:checked ~ .toggle-track {
  background: var(--accent);
  border-color: var(--accent);
}

.sync-toggle-label input:checked ~ .toggle-track::after {
  transform: translateX(18px);
}

.dropzone {
  padding: 16px;
}

.dropzone p {
  font-size: 14px;
  line-height: 1.55;
  color: var(--muted);
}

.dropzone input {
  margin-top: 12px;
}

.preview-card {
  min-height: 160px;
  margin-top: 12px;
  padding: 14px;
  display: grid;
  place-items: center;
  color: var(--muted);
}

.preview-card img {
  width: 100%;
  max-height: 280px;
  object-fit: contain;
  border-radius: 12px;
}

.device-name-editor {
  margin-bottom: 8px;
}

.device-name-editor .field-label {
  display: block;
  margin-bottom: 6px;
}

/* 连接设备模块主操作按钮（连接/保存） */
#joinSessionButton,
#saveDeviceNameButton {
  min-width: 84px;
  padding: 0 16px;
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.01em;
  background: linear-gradient(180deg, #1674e6, #0a64d6);
  border-color: rgba(7, 62, 140, 0.44);
  box-shadow: 0 8px 18px rgba(10, 100, 214, 0.2);
}

#joinSessionButton:hover,
#saveDeviceNameButton:hover {
  background: linear-gradient(180deg, #1b7cf0, #0b68df);
  border-color: rgba(7, 62, 140, 0.54);
  box-shadow: 0 10px 22px rgba(10, 100, 214, 0.24);
}

#joinSessionButton:active,
#saveDeviceNameButton:active {
  transform: translateY(0);
  box-shadow: 0 4px 10px rgba(10, 100, 214, 0.2);
}

#joinSessionButton:focus-visible,
#saveDeviceNameButton:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(10, 100, 214, 0.24), 0 8px 18px rgba(10, 100, 214, 0.2);
}

.remote-image-preview {
  margin: 0;
  display: grid;
  gap: 10px;
}

.remote-image-preview figcaption,
.remote-asset-state,
.remote-file-copy {
  display: grid;
  gap: 8px;
}

.remote-image-preview figcaption strong,
.remote-asset-state strong,
.remote-file-copy strong {
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
}

.remote-image-preview figcaption span,
.remote-asset-state p,
.remote-file-copy span {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.asset-progress {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(81, 96, 113, 0.16);
}

.asset-progress-bar {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(10, 100, 214, 0.56), rgba(10, 100, 214, 0.92));
  transition: width 180ms ease;
}

.remote-file-item {
  align-items: stretch;
}

.history-panel {
  min-height: 290px;
}

.history-list {
  max-height: 440px;
  overflow: auto;
  padding-right: 4px;
}

.history-item {
  gap: 8px;
}

.history-content {
  display: -webkit-box;
  margin-top: 3px;
  overflow: hidden;
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  word-break: break-word;
}

.history-progress-slot {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.history-progress-slot span {
  color: var(--muted);
  font-size: 12px;
}

.history-icon-button {
  min-width: 38px;
  min-height: 24px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

.history-icon-button:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.history-item.is-pinned {
  border-color: rgba(10, 100, 214, 0.24);
  background: var(--surface-pinned);
}

.history-item.is-pinned .history-pin-action {
  color: var(--accent-strong);
  border-color: rgba(10, 100, 214, 0.22);
  background: rgba(10, 100, 214, 0.08);
}

.history-item.is-new-flash {
  animation: history-new-flash 1.2s ease;
}

@keyframes history-new-flash {
  0% {
    box-shadow: 0 0 0 0 rgba(10, 100, 214, 0.38);
    border-color: rgba(10, 100, 214, 0.5);
    background: var(--flash-bg);
  }
  60% {
    box-shadow: 0 0 0 8px rgba(10, 100, 214, 0);
    border-color: rgba(10, 100, 214, 0.28);
  }
  100% {
    box-shadow: none;
  }
}

.file-list {
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
}

.file-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.file-list li span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.file-list li span:last-child {
  flex-shrink: 0;
  color: var(--muted);
  font-size: 12px;
}

pre {
  font-size: 13px;
  line-height: 1.55;
  color: var(--muted);
}

pre {
  white-space: pre-wrap;
  word-break: break-word;
}

@media (max-width: 1080px) {
  .window-content {
    grid-template-columns: 1fr;
  }
}

/* ── Bottom Navigation (mobile only) ── */
.bottom-nav {
  display: none;
  height: 64px;
  padding: 6px 8px;
  border-top: 1px solid var(--line);
  background: linear-gradient(180deg, var(--panel-strong), var(--panel));
  backdrop-filter: blur(20px);
  gap: 4px;
}

.nav-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: color 150ms ease, background 150ms ease, border-color 150ms ease;
}

.nav-tab svg {
  width: 20px;
  height: 20px;
}

.nav-tab.is-active {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: rgba(10, 100, 214, 0.16);
}

/* Badge on history nav tab */
.nav-tab[data-target="history"] .nav-badge {
  display: inline-block;
  position: absolute;
  top: 6px;
  right: calc(50% - 18px);
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  pointer-events: none;
}

.nav-tab[data-target="history"] {
  position: relative;
}

@media (max-width: 720px) {
  body {
    overflow: hidden;
  }

  .window-shell {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    min-height: unset;
    margin: 0;
    padding: 0;
    border-radius: 0;
    border: none;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .window-titlebar {
    flex-shrink: 0;
    flex-direction: row;
    align-items: center;
    padding: 0 16px;
    height: 52px;
    min-height: unset;
    border-bottom: 1px solid var(--line);
  }

  .window-titlebar h1 {
    font-size: 16px;
  }

  .titlebar-status {
    flex-direction: row;
    gap: 8px;
  }

  .window-content {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    position: relative;
    display: block;
    padding: 0;
  }

  .main-column {
    display: contents;
  }

  .sidebar-column,
  .workspace-panel {
    position: absolute;
    inset: 0;
    margin: 0;
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-top: none;
    border-bottom: none;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    display: none;
    padding: 16px;
  }

  .sidebar-column.page-active,
  .workspace-panel.page-active {
    display: block;
  }

  .bottom-nav {
    display: flex;
    flex-shrink: 0;
    position: relative;
    z-index: 10;
  }

  /* Preserve row layout for key flex containers */
  .section-heading,
  .inline-field {
    flex-direction: row;
    align-items: center;
  }

  .button-row {
    flex-direction: column;
    align-items: stretch;
  }

  .session-code-card strong {
    font-size: 26px;
  }

  .session-join-field {
    grid-template-columns: minmax(0, 1fr);
  }

  .button-stack {
    grid-template-columns: minmax(0, 1fr);
  }

  .button-stack .primary-button {
    grid-column: auto;
  }

  .composer-tabs {
    display: flex;
    overflow-x: auto;
  }

  .history-list {
    max-height: none;
  }

  .clipboard-panel {
    min-height: unset;
  }

  .history-panel {
    min-height: unset;
  }

  .richtext-editor {
    min-height: 140px;
  }
}
.online-preview {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
}
.online-preview[hidden] {
  display: none !important;
}
.online-preview-mask {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.38);
  backdrop-filter: blur(4px);
}
.online-preview-panel {
  position: relative;
  width: min(820px, calc(100vw - 28px));
  max-height: min(82vh, 760px);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  background: var(--surface-preview);
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.24);
  overflow: hidden;
}
.online-preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft);
}
.online-preview-head h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}
.online-preview-body {
  padding: 14px;
  overflow: auto;
}
.online-preview-body img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  border-radius: 10px;
}
.online-preview-text {
  line-height: 1.6;
  color: var(--text);
  word-break: break-word;
}
.online-preview-plain {
  margin: 0;
  white-space: pre-wrap;
  font: inherit;
  line-height: 1.6;
  color: var(--text);
}
.online-preview-image-caption {
  margin-top: 10px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}

/* ── Dark mode ──────────────────────────────────────────────────────────── */
.theme-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  padding: 0;
}

.theme-icon-light,
.theme-icon-dark {
  display: block;
}

.theme-icon-dark {
  display: none;
}

/* In dark mode the moon icon hides, sun icon shows */
html.dark .theme-icon-light {
  display: none;
}

html.dark .theme-icon-dark {
  display: block;
}

@media (prefers-color-scheme: dark) {
  html:not(.light) .theme-icon-light {
    display: none;
  }
  html:not(.light) .theme-icon-dark {
    display: block;
  }
}

/* Dark variables — applied when html.dark class present OR system dark + not forced light */
html.dark {
  color-scheme: dark;
  --bg: #1a1d23;
  --mica-tint: rgba(28, 32, 40, 0.88);
  --window: rgba(36, 40, 50, 0.76);
  --window-strong: rgba(42, 46, 58, 0.94);
  --panel: rgba(32, 36, 46, 0.72);
  --panel-strong: rgba(40, 44, 56, 0.9);
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.13);
  --text: #e8eaef;
  --muted: #8b93a8;
  --accent: #4a9eff;
  --accent-strong: #6db3ff;
  --accent-soft: rgba(74, 158, 255, 0.14);
  --warn-soft: rgba(255, 120, 80, 0.15);
  --shadow-window: 0 28px 60px rgba(0, 0, 0, 0.48);
  --shadow-panel: inset 0 1px 0 rgba(255, 255, 255, 0.07);
  /* Surface backgrounds */
  --bg-gradient: radial-gradient(circle at 18% 18%, rgba(74, 158, 255, 0.08), transparent 28%), radial-gradient(circle at 78% 12%, rgba(74, 120, 200, 0.06), transparent 24%), linear-gradient(180deg, #12151c 0%, #1a1d25 42%, #1e2230 100%);
  --mica-overlay: linear-gradient(135deg, rgba(255, 255, 255, 0.04), transparent 34%), linear-gradient(315deg, rgba(255, 255, 255, 0.02), transparent 32%);
  --window-bg-end: rgba(28, 32, 42, 0.72);
  --surface-1: rgba(255, 255, 255, 0.05);
  --surface-2: rgba(255, 255, 255, 0.06);
  --surface-3: rgba(255, 255, 255, 0.08);
  --surface-4: rgba(255, 255, 255, 0.07);
  --surface-5: rgba(255, 255, 255, 0.07);
  --surface-hover: rgba(255, 255, 255, 0.14);
  --surface-input-focus: rgba(255, 255, 255, 0.12);
  --surface-toolbar: rgba(255, 255, 255, 0.06);
  --surface-tabs: rgba(0, 0, 0, 0.22);
  --surface-tab-active: rgba(255, 255, 255, 0.1);
  --surface-device: rgba(255, 255, 255, 0.06);
  --surface-code-card: linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.04));
  --surface-preview: rgba(22, 25, 33, 0.98);
  --surface-qr: rgba(255, 255, 255, 0.06);
  --surface-pinned: linear-gradient(180deg, rgba(74, 158, 255, 0.12), rgba(74, 158, 255, 0.06));
  --flash-bg: rgba(74, 120, 200, 0.28);
  --hover-overlay: rgba(255, 255, 255, 0.1);
  --warn-text: #f0a050;
  --badge-idle-bg: rgba(255, 255, 255, 0.1);
}

@media (prefers-color-scheme: dark) {
  html:not(.light) {
    color-scheme: dark;
    --bg: #1a1d23;
    --mica-tint: rgba(28, 32, 40, 0.88);
    --window: rgba(36, 40, 50, 0.76);
    --window-strong: rgba(42, 46, 58, 0.94);
    --panel: rgba(32, 36, 46, 0.72);
    --panel-strong: rgba(40, 44, 56, 0.9);
    --line: rgba(255, 255, 255, 0.08);
    --line-strong: rgba(255, 255, 255, 0.13);
    --text: #e8eaef;
    --muted: #8b93a8;
    --accent: #4a9eff;
    --accent-strong: #6db3ff;
    --accent-soft: rgba(74, 158, 255, 0.14);
    --warn-soft: rgba(255, 120, 80, 0.15);
    --shadow-window: 0 28px 60px rgba(0, 0, 0, 0.48);
    --shadow-panel: inset 0 1px 0 rgba(255, 255, 255, 0.07);
    /* Surface backgrounds */
    --bg-gradient: radial-gradient(circle at 18% 18%, rgba(74, 158, 255, 0.08), transparent 28%), radial-gradient(circle at 78% 12%, rgba(74, 120, 200, 0.06), transparent 24%), linear-gradient(180deg, #12151c 0%, #1a1d25 42%, #1e2230 100%);
    --mica-overlay: linear-gradient(135deg, rgba(255, 255, 255, 0.04), transparent 34%), linear-gradient(315deg, rgba(255, 255, 255, 0.02), transparent 32%);
    --window-bg-end: rgba(28, 32, 42, 0.72);
    --surface-1: rgba(255, 255, 255, 0.05);
    --surface-2: rgba(255, 255, 255, 0.06);
    --surface-3: rgba(255, 255, 255, 0.08);
    --surface-4: rgba(255, 255, 255, 0.07);
    --surface-5: rgba(255, 255, 255, 0.07);
    --surface-hover: rgba(255, 255, 255, 0.14);
    --surface-input-focus: rgba(255, 255, 255, 0.12);
    --surface-toolbar: rgba(255, 255, 255, 0.06);
    --surface-tabs: rgba(0, 0, 0, 0.22);
    --surface-tab-active: rgba(255, 255, 255, 0.1);
    --surface-device: rgba(255, 255, 255, 0.06);
    --surface-code-card: linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.04));
    --surface-preview: rgba(22, 25, 33, 0.98);
    --surface-qr: rgba(255, 255, 255, 0.06);
    --surface-pinned: linear-gradient(180deg, rgba(74, 158, 255, 0.12), rgba(74, 158, 255, 0.06));
    --flash-bg: rgba(74, 120, 200, 0.28);
    --hover-overlay: rgba(255, 255, 255, 0.1);
    --warn-text: #f0a050;
    --badge-idle-bg: rgba(255, 255, 255, 0.1);
  }
}