.screen-frame {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100%;
  border-right: 1px solid var(--line-soft);
  background: var(--bg-surface);
  overflow: clip;
}

.screen-frame:last-child {
  border-right: none;
}

.screen-topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 52px;
  padding: 0 8px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--bg-subtle);
}

.screen-leading,
.screen-trailing {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.screen-copy {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.screen-eyebrow,
.section-kicker,
.field-label,
.metric-label,
.studio-kicker,
.section-label {
  margin: 0;
  color: var(--text-soft);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
}

.screen-title {
  margin: 0;
  overflow: hidden;
  color: var(--text-strong);
  font-size: 1.02rem;
  font-weight: 650;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.screen-subtitle {
  margin: 2px 0 0;
  overflow: hidden;
  color: var(--text-soft);
  font-size: 0.82rem;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.screen-content {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-height: 0;
  padding: 8px;
  overflow: auto;
}

.screen-footer {
  padding: 8px;
  border-top: 1px solid var(--line-soft);
  background: var(--bg-subtle);
}

.icon-button,
.action-button,
.tab-button,
.tag-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}

.icon-button {
  width: 36px;
  min-width: 36px;
  min-height: 36px;
  padding: 0;
  border-color: var(--line-soft);
  background: var(--bg-surface);
  color: var(--text-body);
}

.icon-button-svg,
.icon-button-svg svg {
  display: block;
  width: 18px;
  height: 18px;
}

.icon-button-svg svg {
  stroke: currentColor;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.icon-button:hover,
.action-button:hover,
.tab-button:hover,
.list-row:hover {
  border-color: var(--line-strong);
  background: var(--bg-muted);
}

.action-button {
  min-height: 36px;
  padding: 0 12px;
}

.action-button-block {
  width: 100%;
}

.action-button-primary {
  border-color: var(--bg-accent);
  background: var(--bg-accent);
  color: var(--text-inverse);
}

.action-button-secondary {
  border-color: var(--accent-secondary-border);
  background: var(--bg-accent-soft);
  color: var(--accent-text);
}

.action-button-quiet {
  border-color: var(--line-soft);
  background: var(--bg-surface);
  color: var(--text-body);
}

.action-button:disabled,
.icon-button:disabled {
  cursor: default;
  opacity: 0.55;
}

.section-card {
  min-width: 0;
}

.section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line-soft);
}

.section-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 650;
}

.section-description {
  margin: 0;
  color: var(--text-soft);
  font-size: 0.82rem;
}

.section-body {
  display: grid;
  gap: 6px;
  padding: 8px;
}

.stack-gap {
  display: grid;
  gap: 6px;
}

.list-row,
.data-row,
.sync-device-row,
.share-row {
  width: 100%;
  min-width: 0;
  min-height: 52px;
  padding: 8px 10px;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  background: var(--bg-surface);
}

.list-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  text-align: left;
}

.list-row-selected {
  border-color: var(--accent-border);
  background: var(--accent-selected);
}

.conflict-group {
  display: grid;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--warning-border);
  border-radius: 6px;
  background: var(--bg-warning);
}

.conflict-summary {
  min-width: 0;
}

.conflict-version {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 56px;
  padding: 8px 10px;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  background: var(--bg-surface);
}

.conflict-version-selected {
  border-color: var(--accent-border);
  background: var(--accent-selected);
}

.conflict-actions {
  display: flex;
  justify-content: flex-end;
}

.conflict-ancestor-count {
  margin: 0;
  color: var(--text-soft);
  font-size: 0.82rem;
  line-height: 1.35;
}

.data-row,
.sync-device-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
}

.split-row,
.sync-device-row {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.row-copy {
  min-width: 0;
}

.row-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  justify-self: end;
  gap: 12px;
}

.row-actions .action-button {
  min-width: 88px;
}

.row-actions .icon-button.action-button-primary:hover {
  border-color: var(--bg-accent);
  background: var(--bg-accent);
  color: var(--text-inverse);
  filter: brightness(1.1);
}

.row-actions .action-button.action-button-secondary:hover {
  border-color: var(--accent-border);
  background: var(--accent-selected);
  color: var(--accent-text);
}

.row-title {
  margin: 0;
  overflow: hidden;
  font-size: 0.94rem;
  font-weight: 600;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-meta,
.row-detail,
.field-hint,
.empty-copy,
.share-amount {
  margin: 3px 0 0;
  overflow-wrap: anywhere;
  color: var(--text-soft);
  font-size: 0.82rem;
  line-height: 1.35;
}

.row-detail {
  color: var(--text-body);
}

.row-trailing {
  display: flex;
  align-items: center;
  gap: 6px;
}

.mono-copy,
.invite-url {
  font-family: ui-monospace, "SFMono-Regular", "Cascadia Mono", "Segoe UI Mono", monospace;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.field-block {
  display: grid;
  gap: 5px;
}

.field-control {
  display: grid;
}

.ui-input,
.ui-select,
.ui-textarea,
.share-input {
  width: 100%;
  min-height: 36px;
  padding: 7px 9px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--bg-surface);
  color: var(--text-strong);
  outline: none;
}

.ui-input:focus,
.ui-select:focus,
.ui-textarea:focus,
.share-input:focus {
  border-color: var(--bg-accent);
  box-shadow: 0 0 0 2px var(--focus-ring);
}

.ui-textarea {
  min-height: 92px;
  resize: vertical;
}

.combobox {
  position: relative;
}

.combobox-list {
  position: fixed;
  z-index: 200;
  max-height: 240px;
  overflow-y: auto;
  margin: 0;
  padding: 4px 0;
  list-style: none;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--bg-surface);
  box-shadow: var(--shadow-overlay);
}

.combobox-option {
  padding: 8px 10px;
  font-size: 0.88rem;
  cursor: pointer;
  color: var(--text-body);
}

.combobox-option:hover {
  background: var(--bg-muted);
  color: var(--text-strong);
}

.chip-row,
.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag-pill {
  min-height: 30px;
  padding: 0 10px;
  border-color: var(--line-soft);
  background: var(--bg-surface);
  color: var(--text-body);
}

.tag-pill-active {
  border-color: var(--accent-border);
  background: var(--bg-accent-soft);
  color: var(--accent-text);
}

.toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
  z-index: 9999;
  pointer-events: none;
}

.toast {
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 0.875rem;
  white-space: nowrap;
  animation: toast-show 8.3s ease forwards;
  pointer-events: auto;
}

.toast-info {
  background: var(--toast-info-bg);
  color: var(--toast-info-text);
}

.toast-error {
  background: var(--toast-error-bg);
  color: var(--toast-error-text);
}

.circular-progress {
  width: 1em;
  height: 1em;
  animation: circular-progress-spin 2s linear infinite;
}

.circular-progress-track {
  fill: none;
  stroke: currentColor;
  opacity: 0.2;
  stroke-width: 3;
}

.circular-progress-fill {
  fill: none;
  stroke: currentColor;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: 75.4;
  stroke-dashoffset: 74;
  transform-origin: center;
  animation: circular-progress-dash 1.4s ease-in-out infinite both;
}

@keyframes circular-progress-spin {
  0%   { transform: rotateZ(0deg); }
  100% { transform: rotateZ(360deg); }
}

@keyframes circular-progress-dash {
  0%, 25% {
    stroke-dashoffset: 74;
    transform: rotate(0deg);
  }
  50%, 75% {
    stroke-dashoffset: 20;
    transform: rotate(45deg);
  }
  100% {
    stroke-dashoffset: 74;
    transform: rotate(360deg);
  }
}

@keyframes toast-show {
  0%   { opacity: 0; transform: translateY(-8px); }
  4%   { opacity: 1; transform: translateY(0); }
  88%  { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-8px); }
}

.empty-column {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
}

.safe-content-area {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.settings-overlay,
.sheet-overlay {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
}

.settings-backdrop,
.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: var(--overlay-backdrop);
}

.settings-panel,
.sheet-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(980px, 100%);
  max-height: min(760px, calc(100% - 36px));
  min-height: min(620px, calc(100% - 36px));
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--bg-surface);
  box-shadow: var(--shadow-overlay);
  overflow: clip;
}

.sheet-panel {
  width: min(540px, 100%);
  min-height: 0;
}

.settings-header,
.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 54px;
  padding: 9px 10px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--bg-subtle);
}

.settings-title-block,
.sheet-copy {
  min-width: 0;
}

.settings-title,
.sheet-title {
  margin: 0;
  overflow: hidden;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-subtitle,
.sheet-description {
  margin: 2px 0 0;
  overflow-wrap: anywhere;
  color: var(--text-soft);
  font-size: 0.78rem;
  line-height: 1.3;
}

.tab-button {
  padding: 0 12px;
  border-color: var(--line-soft);
  background: var(--bg-surface);
  color: var(--text-body);
}

.tab-button-active {
  border-color: var(--accent-border);
  background: var(--bg-accent-soft);
  color: var(--accent-text);
}

.settings-nav-group {
  margin-top: 4px;
}

.settings-nav-group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px 2px;
}

.settings-nav-group-header::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line-soft);
}

.settings-nav-group-title {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-soft);
  white-space: nowrap;
  flex-shrink: 0;
}

.settings-layout {
  display: flex;
  flex: 1;
  min-height: 0;
}

.settings-sidebar {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 156px;
  padding: 8px;
  border-right: 1px solid var(--line-soft);
  background: var(--bg-subtle);
  flex-shrink: 0;
  overflow-y: auto;
}

.settings-nav-item {
  -webkit-appearance: none;
  appearance: none;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 34px;
  padding: 0 10px;
  border: none;
  border-radius: 6px;
  background: transparent;
  box-shadow: none;
  font-size: 0.88rem;
  font-weight: 600;
  text-align: left;
  color: var(--text-body);
  white-space: nowrap;
  cursor: pointer;
}

.settings-nav-label {
  flex: 1;
}

.settings-nav-chevron {
  display: block;
  width: 16px;
  height: 16px;
  opacity: 0.35;
  flex-shrink: 0;
}

.settings-nav-item:hover {
  background: var(--overlay-hover);
}

.settings-nav-item-active {
  background: var(--overlay-active);
  color: var(--text-strong);
}

.settings-content-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.settings-mobile-back {
  display: none;
}

.settings-body,
.sheet-body {
  flex: 1;
  min-height: 0;
  padding: 10px;
  overflow: auto;
}

.settings-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* About stays behind an explicit entry point and uses only bundled content. */
.about-dialog {
  width: min(660px, calc(100% - 32px));
  max-width: none;
  max-height: calc(100dvh - 32px);
  margin: auto;
  padding: 0;
  border: 1px solid var(--line-soft);
  border-radius: 18px;
  background: var(--bg-surface);
  color: var(--text-body);
  box-shadow: var(--shadow-overlay);
  overflow: hidden;
}

.about-dialog::backdrop {
  background: var(--overlay-backdrop);
  backdrop-filter: blur(3px);
}

.about-shell { display: flex; flex-direction: column; max-height: calc(100dvh - 36px); }
.about-shell > .sheet-header { flex-shrink: 0; padding-inline: 18px; }
.about-scroll { overflow-y: auto; overflow-wrap: anywhere; overscroll-behavior: contain; user-select: text; padding: 32px clamp(20px, 6vw, 44px); }
.about-link-error { margin: 12px; flex-shrink: 0; }
.about-hero { padding-bottom: 30px; }
.about-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.about-wordmark { font-size: 1.5rem; font-weight: 650; letter-spacing: -0.05em; color: var(--text-strong); }
/* Preserve the logo artwork and keep its dark strokes visible in either theme. */
.about-mark { --logo-surface: #fff; display: flex; width: 56px; height: 56px; padding: 6px; box-sizing: border-box; flex-shrink: 0; border-radius: 12px; background: var(--logo-surface); }
.about-mark svg { display: block; width: 100%; height: 100%; }
.about-hero h3 { margin: 0; max-width: 17ch; font-size: clamp(1.8rem, 5vw, 2.5rem); line-height: 1.15; letter-spacing: -0.04em; font-weight: 650; color: var(--text-strong); text-wrap: balance; }
.about-summary { margin: 16px 0 20px; font-size: 1rem; line-height: 1.6; }
.about-principles { display: flex; flex-wrap: wrap; gap: 8px; padding: 0; margin: 0; list-style: none; }
.about-principles li { border: 1px solid var(--line-soft); border-radius: 99px; padding: 5px 10px; color: var(--text-soft); font-size: 0.75rem; }
.about-section { padding: 25px 0; border-top: 1px solid var(--line-soft); }
.about-section h3 { margin: 0 0 12px; color: var(--text-strong); font-size: 1.05rem; line-height: 1.4; letter-spacing: -0.015em; }
.about-section p { margin: 10px 0; line-height: 1.7; font-size: 0.93rem; }
.about-link { display: inline-flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 44px; padding: 6px 0; color: var(--accent-text); font-weight: 600; font-size: 0.9rem; text-decoration: none; }
.about-link:hover { text-decoration: underline; text-underline-offset: 4px; }
.about-link:focus-visible { outline: 2px solid var(--bg-accent); outline-offset: 4px; border-radius: 3px; }
.about-support { margin-bottom: 0; padding-bottom: 0; }
.about-support .about-link { padding: 8px 16px; margin-top: 6px; border: 1px solid var(--accent-border); border-radius: 10px; background: var(--bg-accent-soft); }

.license-overlay {
  position: fixed;
  z-index: 100;
}

.license-panel {
  width: min(980px, 100%);
  height: min(760px, calc(100% - 36px));
}

.license-scope { margin: 8px 12px; }
.license-layout { display: flex; flex: 1; min-height: 0; }
.license-sidebar { display: flex; flex-direction: column; width: 240px; min-width: 0; padding: 8px; border-right: 1px solid var(--line-soft); }
.license-software-list { overflow: auto; min-height: 0; margin-top: 8px; }
.license-software { display: flex; flex-direction: column; gap: 2px; width: 100%; padding: 8px; border: 0; text-align: left; color: var(--text-body); background: transparent; cursor: pointer; }
.license-software[aria-pressed="true"] { background: var(--bg-accent-soft); }
.license-software small { color: var(--text-soft); }
.license-documents { flex: 1; min-width: 0; overflow: auto; padding: 12px; user-select: text; }
.license-source { overflow-wrap: anywhere; }
.license-document { border-top: 1px solid var(--line-soft); padding-top: 8px; }
.license-document pre { font: inherit; font-size: 0.85rem; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }

@media (max-width: 720px) {
  .license-layout { flex-direction: column; }
  .license-sidebar { width: auto; max-height: 180px; border-right: 0; border-bottom: 1px solid var(--line-soft); }
}


.result-panel,
.invite-panel {
  display: grid;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  background: var(--bg-subtle);
}

.result-actions {
  display: flex;
  justify-content: flex-end;
}

.invite-qr {
  display: flex;
  justify-content: center;
}

.invite-qr svg {
  width: 200px;
  height: 200px;
}

.invite-url {
  margin: 0;
  max-height: 160px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--text-body);
  font-size: 0.78rem;
  line-height: 1.4;
}

.share-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.share-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.share-toggle span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.share-side {
  display: flex;
  align-items: center;
  gap: 6px;
}

.share-input {
  width: 70px;
}

.form-error {
  margin: 0;
  padding: 8px 10px;
  border: 1px solid var(--error-border);
  border-radius: 6px;
  background: var(--bg-error);
  color: var(--error-text);
  font-size: 0.9rem;
}

.update-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 14px;
  background: var(--bg-accent-soft);
  border-bottom: 1px solid var(--accent-secondary-border);
  flex-shrink: 0;
}

.update-banner-text {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--accent-text);
}

@media (max-width: 1199px) {
  .screen-frame {
    flex: 1;
    min-height: 0;
    height: auto;
  }

  .settings-overlay {
    padding: 0;
  }

  .settings-panel {
    width: 100%;
    min-height: 100vh;
    max-height: 100vh;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }

}

@media (max-width: 720px) {
  .field-grid,
  .share-row,
  .split-row,
  .sync-device-row {
    grid-template-columns: 1fr;
  }

  .button-row,
  .share-side {
    justify-content: stretch;
  }

  .button-row .action-button,
  .share-side .action-button {
    flex: 1 1 auto;
  }

  .settings-sidebar {
    width: 100%;
    border-right: none;
  }

  .settings-sidebar-hidden {
    display: none;
  }

  .settings-nav-item-active {
    background: transparent;
    color: var(--text-body);
  }

  .settings-content-area-hidden {
    display: none;
  }

  .settings-mobile-back {
    display: flex;
    align-items: center;
    gap: 6px;
    min-height: 48px;
    padding: 0 8px;
    border-bottom: 1px solid var(--line-soft);
    background: var(--bg-subtle);
    flex-shrink: 0;
  }

  .settings-nav-item {
    min-height: 48px;
    font-size: 0.94rem;
    border-radius: 0;
  }
}
