/* App layout on top of jp-retro-pop theme.css */

:root {
  --indent: 20px;
  --row-h: 28px;
  --toggle-w: 16px;
  --handle-w: 16px;
  --app-max: 1100px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

.app {
  height: 100%;
  width: 100%;
  max-width: var(--app-max);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-left: 2px solid transparent;
  border-right: 2px solid transparent;
}

@media (min-width: 1101px) {
  .app {
    border-left-color: var(--pop-ink);
    border-right-color: var(--pop-ink);
    background: var(--pop-app-rail);
  }
}

.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 2px solid var(--pop-ink);
  background: var(--pop-surface);
  position: relative;
  z-index: 40;
  overflow: visible;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.brand-mark {
  font-size: 1.45rem;
}

.tabs {
  display: inline-flex;
  padding: 4px;
  border: 2px solid var(--pop-ink);
  border-radius: 999px;
  background: var(--pop-bg);
  gap: 4px;
}

.tab {
  border: 0;
  background: transparent;
  padding: 7px 18px;
  border-radius: 999px;
  color: var(--pop-dim);
  font-weight: 800;
}

.tab.is-active {
  background: var(--pop-accent);
  color: var(--pop-on-accent);
}

.topbar-end {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  position: relative;
  z-index: 41;
  overflow: visible;
}

.topbar-menu-btn {
  display: none;
}

.topbar-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 4px;
  position: relative;
  z-index: 41;
  overflow: visible;
}

/* Desktop: actions stay inline; panel chrome only applies on mobile */
.topbar-actions.tool-panel--topbar {
  position: static;
  min-width: 0;
  max-width: none;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  display: flex !important;
}

.menu-item {
  display: block;
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 8px 12px;
  border-radius: 8px;
  font-weight: 800;
  font-size: 0.85rem;
  color: var(--pop-ink);
  cursor: pointer;
  font-family: inherit;
}

.menu-item:hover {
  background: var(--pop-hover-fill);
}

.topbar-action-label {
  display: none;
}

.file-menu-item {
  box-sizing: border-box;
}

.help-dialog {
  border: 2px solid var(--pop-ink);
  border-radius: 16px;
  padding: 0;
  max-width: min(94vw, 420px);
  width: 100%;
  background: var(--pop-surface);
  color: var(--pop-ink);
  box-shadow: var(--pop-shadow-hard);
  font-family: inherit;
}

.help-dialog::backdrop {
  background: var(--pop-backdrop);
}

.help-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 14px 10px 18px;
  border-bottom: 2px solid var(--pop-ink);
}

.help-dialog-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
}

.help-dialog-body {
  padding: 14px 18px 18px;
  max-height: min(72vh, 560px);
  overflow: auto;
}

.about-dialog-copy {
  margin: 0 0 14px;
  color: var(--pop-dim);
}

.about-dialog-links {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.about-dialog-links a {
  display: block;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--pop-ink);
  font-weight: 800;
  text-decoration: none;
}

.about-dialog-links a:hover {
  background: var(--pop-hover-fill);
}

.about-dialog-contact {
  margin: 16px 0 0;
  padding-top: 12px;
  border-top: 1px solid color-mix(in srgb, var(--pop-ink) 20%, transparent);
  color: var(--pop-dim);
  font-size: 0.86rem;
}

.about-dialog-contact a {
  color: var(--pop-accent-dark);
  font-weight: 800;
}

.help-tutorial-bar {
  display: flex;
  justify-content: center;
  margin: 8px 0 18px;
  padding: 8px 12px 20px;
  border-bottom: 1px solid var(--pop-ink-mid);
}

.help-tutorial-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  min-width: 10.5em;
  text-align: center;
  text-decoration: none;
  padding: 10px 28px;
  border: 2px solid var(--pop-ink);
  border-radius: var(--pop-radius-btn, 10px);
  background: var(--pop-input-fill);
  color: var(--pop-ink);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 800;
  box-shadow: var(--pop-shadow-sm);
}

.help-tutorial-link:hover {
  background: var(--pop-hover-fill);
}

body[data-theme="formal"] .help-tutorial-link,
body[data-theme="geek"] .help-tutorial-link,
body[data-theme="calm"] .help-tutorial-link {
  box-shadow: none;
  border-width: 1px;
  border-color: var(--pop-divider, var(--pop-ink-mid));
}

.help-section {
  margin-bottom: 0;
}

.help-section h4 {
  margin: 0 0 4px;
  font-size: 0.74rem;
  font-weight: 800;
  color: var(--pop-dim);
}

.help-section p {
  margin: 0;
  padding: 3px 0;
  font-size: 0.84rem;
  font-weight: 700;
  line-height: 1.5;
  color: var(--pop-ink);
}

.help-keys-group {
  margin-top: 12px;
}

.help-keys-group:first-of-type {
  margin-top: 0;
}

.help-section--mobile {
  display: none;
}

@media (max-width: 900px) {
  .help-section--desktop {
    display: none;
  }

  .help-section--mobile {
    display: block;
  }
}

.help-section kbd {
  display: inline-block;
  border: 2px solid var(--pop-ink);
  border-radius: 6px;
  background: var(--pop-input-fill);
  padding: 0 6px;
  margin-right: 2px;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 800;
  box-shadow: 1px 1px 0 var(--pop-ink-mid);
}

.pop-btn--sm {
  padding: 6px 14px;
  font-size: 0.82rem;
  box-shadow: 2px 2px 0 var(--pop-shadow-ink-18);
  white-space: nowrap;
}

.pop-btn--sm:active {
  transform: translate(2px, 2px);
}

.pop-btn.is-active {
  background: var(--pop-marker);
}

.danger-btn {
  background: var(--pop-danger-soft);
}

.workspace {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
  overflow: hidden;
}

.main-pane,
.detail-pane {
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.main-pane {
  border-right: 2px solid var(--pop-ink);
  min-height: 0;
  overflow: hidden;
}

.view {
  display: none;
  flex-direction: column;
  min-height: 0;
  flex: 1;
  overflow: hidden;
}

.view.is-active {
  display: flex;
}

.view-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 2px solid var(--pop-ink);
  background: var(--pop-tools-bg);
  flex-wrap: wrap;
}

.view-tools {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-bottom: 2px solid var(--pop-ink);
  background: var(--pop-tools-bg);
  height: 42px;
  box-sizing: border-box;
  position: relative;
  z-index: 5;
}

.view-tools .tool-pop--end {
  margin-left: auto;
}

.tool-pop {
  position: relative;
}

.tool-icon-btn {
  width: 30px;
  height: 30px;
  border: 2px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--pop-dim);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.tool-icon-btn:hover {
  background: var(--pop-ink-soft);
  color: var(--pop-ink);
}

.tool-icon-btn.is-on,
.tool-pop.is-open > .tool-icon-btn {
  border-color: var(--pop-ink);
  background: var(--pop-input-fill);
  color: var(--pop-ink);
}

.tool-icon-btn.is-on {
  background: var(--pop-marker);
}

.tool-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 20;
  min-width: 220px;
  max-width: min(92vw, 360px);
  padding: 10px;
  background: var(--pop-surface);
  border: 2px solid var(--pop-ink);
  border-radius: 12px;
  box-shadow: var(--pop-shadow);
}

.tool-panel--menu {
  min-width: 140px;
  max-width: min(92vw, 200px);
  padding: 6px;
  left: auto !important;
  right: 0;
  z-index: 50;
}

.tool-panel--settings {
  min-width: 260px;
  max-width: min(94vw, 320px);
  left: auto !important;
  right: 0;
  z-index: 50;
  padding: 12px;
}

.settings-section + .settings-section {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--pop-ink-dash);
}

.settings-heading {
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--pop-dim);
  margin-bottom: 8px;
}

.settings-select {
  width: 100%;
  padding: 8px 10px;
  font-size: 0.84rem;
  font-weight: 700;
  line-height: 1.35;
  border-radius: 10px;
  cursor: pointer;
}

.settings-check-row {
  display: flex;
  align-items: center;
  gap: 2px;
}

.settings-check-row .settings-check {
  flex: 1 1 auto;
  min-width: 0;
}

.settings-check {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 0;
  padding: 6px 4px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.84rem;
  font-weight: 700;
  line-height: 1.35;
  color: var(--pop-ink);
}

.settings-check + .settings-check {
  margin-top: 2px;
}

.settings-check:hover {
  background: var(--pop-hover-fill);
}

.settings-check input {
  margin: 0.2em 0;
  flex-shrink: 0;
  accent-color: var(--pop-accent);
}

.settings-help-btn {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  margin: 0;
  padding: 0;
  border: 1.5px solid var(--pop-ink);
  border-radius: 999px;
  background: var(--pop-input-fill);
  color: var(--pop-ink);
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  box-shadow: 1px 1px 0 var(--pop-shadow-ink-14);
}

.settings-help-btn:hover {
  background: var(--pop-hover-fill);
}

.settings-help-text {
  margin: -2px 2px 8px;
  color: var(--pop-dim);
  font-size: 0.72rem;
  line-height: 1.4;
}

.settings-field {
  display: block;
  margin-top: 8px;
}

.settings-field-label {
  display: block;
  margin: 0 2px 4px;
  color: var(--pop-dim);
  font-size: 0.72rem;
  font-weight: 800;
}

.settings-input {
  width: 100%;
  padding: 8px 10px;
  font-size: 0.78rem;
}

.discord-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.discord-actions--secondary {
  justify-content: space-between;
}

.settings-status {
  min-height: 1.1em;
  color: var(--pop-dim);
  font-size: 0.72rem;
  line-height: 1.35;
}

.settings-status.is-success {
  color: var(--pop-accent);
}

.settings-status.is-error {
  color: var(--pop-danger, #a33d31);
}

.sync-dialog {
  max-width: min(92vw, 480px);
}

.sync-dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0;
}

.sync-passphrase-field {
  margin-top: 12px;
}

.sync-status {
  margin: 12px 0;
  min-height: 1.4em;
}

.lang-menu-btn .lang-code {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1;
  color: inherit;
}

.tool-panel--lang {
  min-width: 120px;
  max-width: min(92vw, 160px);
  padding: 4px;
  right: 0;
  left: auto;
}

.lang-option {
  display: block;
  width: 100%;
  margin: 0;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--pop-ink);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 800;
  text-align: left;
  cursor: pointer;
}

.lang-option:hover {
  background: var(--pop-hover-fill);
}

.lang-option.is-active {
  background: var(--pop-ink-soft);
  color: var(--pop-ink);
}

.topbar-lang-pop {
  position: relative;
}

.tool-panel--wide {
  min-width: 280px;
  max-width: min(94vw, 420px);
}

.tool-panel--sort {
  min-width: 200px;
}

.tool-panel-label {
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--pop-dim);
  margin-bottom: 8px;
}

.inline-search {
  display: inline-flex;
  align-items: center;
  gap: 0;
  min-width: 0;
  height: 30px;
}

.inline-search.is-open {
  gap: 6px;
}

.inline-search-input {
  width: 0;
  min-width: 0;
  height: 30px;
  opacity: 0;
  padding: 0;
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1;
  border-radius: 10px;
  border-width: 0 !important;
  box-sizing: border-box;
  pointer-events: none;
  overflow: hidden;
  transition:
    width 0.2s ease,
    opacity 0.16s ease,
    padding 0.2s ease,
    border-width 0.2s ease;
}

.inline-search.is-open .inline-search-input {
  width: min(42vw, 200px);
  opacity: 1;
  padding: 0 10px;
  border-width: 2px !important;
  pointer-events: auto;
}

@media (prefers-reduced-motion: reduce) {
  .inline-search-input {
    transition: none;
  }
}

.tool-hint {
  margin-left: 4px;
  color: var(--pop-dim);
  font-size: 0.72rem;
  font-weight: 800;
  white-space: nowrap;
}

.tool-status {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--pop-ink-dash);
}

.zoom-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  border-bottom: 2px solid var(--pop-ink);
  background: var(--pop-hover-fill);
  min-height: 44px;
}

.zoom-bar[hidden] {
  display: none !important;
}

.zoom-out-btn {
  flex-shrink: 0;
}

.zoom-crumbs {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  flex-wrap: wrap;
  font-weight: 800;
  font-size: 0.82rem;
}

.zoom-sep {
  color: var(--pop-muted);
  font-weight: 800;
  padding: 0 2px;
}

.zoom-crumb {
  border: 0;
  background: transparent;
  color: var(--pop-dim);
  font: inherit;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 8px;
  max-width: 12em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

.zoom-crumb:hover {
  background: var(--pop-ink-soft);
  color: var(--pop-ink);
}

.zoom-crumb.is-current {
  color: var(--pop-ink);
  background: var(--pop-input-fill);
  border: 2px solid var(--pop-ink);
  cursor: default;
}

.row.is-zoom-root .title-input {
  font-weight: 800;
}

.title-cell {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
}

body.is-title-wrap .title-cell {
  align-items: flex-start;
}

body.is-title-wrap .plain-text-line {
  align-items: flex-start;
}

body.is-title-wrap .progress-wrap {
  margin-top: 6px;
}

.title-grow {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.title-stack {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.title-cell.has-progress .title-stack {
  /* leave room for progress; title truncates first */
  max-width: calc(100% - 58px);
}

.row-submeta {
  display: none;
}

.title-mirror {
  display: block;
  visibility: hidden;
  white-space: pre;
  font-family: inherit;
  font-weight: 700;
  font-size: 0.94rem;
  line-height: 1.35;
  padding: 3px 4px;
  min-height: 1.35em;
  pointer-events: none;
}

body.is-title-wrap .title-mirror {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.row.is-root .title-mirror {
  /* Same size as other rows so handle/▼ stay aligned; weight keeps emphasis */
  font-size: 0.94rem;
  font-weight: 800;
}

.title-grow .title-input {
  position: absolute;
  inset: 0;
  width: 100%;
  min-width: 0;
  text-overflow: ellipsis;
  resize: none;
  overflow: hidden;
}

body:not(.is-title-wrap) .title-grow .title-input {
  white-space: nowrap;
  field-sizing: content;
}

body.is-title-wrap .title-grow .title-input {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  text-overflow: clip;
}

.progress-wrap {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: 0 0 auto;
}

.progress-gauge {
  display: inline-block;
  width: 32px;
  height: 8px;
  border: 2px solid var(--pop-ink);
  border-radius: 999px;
  background: var(--pop-input-fill);
  overflow: hidden;
  flex-shrink: 0;
}

.progress-fill {
  display: block;
  height: 100%;
  background: var(--pop-accent);
  border-radius: 999px;
  min-width: 0;
}

.progress-fill.is-done {
  background: var(--pop-ok);
}

.progress-label {
  font-variant-numeric: tabular-nums;
  font-size: 0.68rem;
  font-weight: 800;
  color: var(--pop-dim);
}

.detail-category {
  font-size: 0.68rem;
  font-weight: 800;
  color: var(--pop-dim);
  letter-spacing: 0.02em;
  line-height: 1.2;
  margin-bottom: 2px;
  padding: 0 2px;
}

.detail-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.detail-title-row .detail-title {
  flex: 1 1 auto;
  min-width: 0;
}

.focus-chip-btn {
  flex-shrink: 0;
  border: 2px solid var(--pop-ink);
  border-radius: 999px;
  background: var(--pop-input-fill);
  color: var(--pop-ink);
  padding: 4px 10px;
  font-size: 0.72rem;
  font-weight: 800;
  white-space: nowrap;
  box-shadow: 2px 2px 0 var(--pop-shadow-ink-14);
}

.focus-chip-btn:hover {
  background: var(--pop-hover-fill);
}

.focus-chip-btn.is-focused {
  background: var(--pop-accent);
  color: var(--pop-on-accent);
}

.date-stamp {
  display: inline-flex;
  align-items: stretch;
  box-sizing: border-box;
  gap: 0;
  border: 2px solid var(--pop-ink);
  border-radius: 999px;
  padding: 0;
  background: var(--pop-input-fill);
  font-family: var(--pop-font);
  line-height: 1.2;
  overflow: hidden;
  vertical-align: middle;
}

.date-stamp-tag,
.date-stamp-val {
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  margin: 0;
  border: 0;
  padding: 0.15em 0.55em;
  font-family: inherit;
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1.2;
}

.date-stamp-tag {
  border-radius: 0;
  letter-spacing: 0.04em;
  background: var(--pop-ink);
  color: var(--pop-on-accent);
}

.date-stamp-val {
  padding-left: 0.45em;
  padding-right: 0.6em;
  font-variant-numeric: tabular-nums;
  color: var(--pop-ink);
}

.date-stamp.is-due .date-stamp-tag {
  background: var(--pop-context-pill);
}

.date-stamp.is-due.is-today {
  background: var(--pop-hover-fill);
}

.date-stamp.is-due.is-today .date-stamp-tag {
  background: var(--pop-accent);
}

.date-stamp.is-due.is-overdue {
  background: var(--pop-danger-soft);
}

.date-stamp.is-due.is-overdue .date-stamp-tag {
  background: var(--pop-danger);
}

.date-stamp.is-completed .date-stamp-tag {
  background: var(--pop-ok);
}

.detail-due-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.detail-due-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.archive-search-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.archive-search-wrap {
  position: relative;
  flex: 1;
  min-width: 200px;
}

.search-input {
  width: 100%;
  padding-right: 36px;
}

.search-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--pop-dim);
  font-size: 1.1rem;
  font-weight: 800;
  line-height: 1;
}

.search-clear:hover {
  background: var(--pop-ink-soft);
  color: var(--pop-ink);
}

.archive-status {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.archive-count {
  color: var(--pop-dim);
  font-size: 0.8rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.archive-load-more {
  display: block;
  margin: 14px auto 0;
}

.archive-load-more[hidden] {
  display: none !important;
}

.archive-filter-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.filter-label {
  color: var(--pop-dim);
  font-size: 0.75rem;
  font-weight: 800;
  min-width: 4.5em;
}

.archive-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.filter-chip {
  border: 2px solid var(--pop-ink);
  background: var(--pop-input-fill);
  color: var(--pop-ink);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 0.78rem;
  font-weight: 800;
  font-family: inherit;
  box-shadow: 2px 2px 0 var(--pop-shadow-ink-14);
  cursor: pointer;
  white-space: nowrap;
}

.filter-chip:hover {
  background: var(--pop-hover-fill);
}

.filter-chip:active {
  transform: translate(2px, 2px);
  box-shadow: none;
}

.filter-chip.is-active {
  background: var(--pop-accent);
  color: var(--pop-on-accent);
}

.archive-range-panel {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
  padding: 2px 0;
}

.tool-panel .archive-filter-row {
  margin-bottom: 8px;
}

.tool-panel .archive-filter-row:last-child {
  margin-bottom: 0;
}

.tool-panel .filter-label {
  min-width: 4em;
}

.archive-range-panel[hidden] {
  display: none !important;
}

.range-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--pop-dim);
}

.range-date {
  padding: 6px 10px;
  font-size: 0.85rem;
  font-weight: 700;
}

.range-tilde {
  color: var(--pop-dim);
  font-weight: 800;
  padding-bottom: 8px;
}

.input-white,
.pop-input.input-white {
  background: var(--pop-input-fill) !important;
}

.outline {
  flex: 1;
  overflow: auto;
  padding: 8px 12px 20px;
  outline: none;
  user-select: none;
  scrollbar-width: thin;
  scrollbar-color: var(--pop-ink-mid) transparent;
}

.outline[hidden] {
  display: none !important;
}

.outline::-webkit-scrollbar {
  width: 8px;
}

.outline::-webkit-scrollbar-track {
  background: transparent;
}

.outline::-webkit-scrollbar-thumb {
  background: var(--pop-ink-mid);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: content-box;
}

.outline::-webkit-scrollbar-thumb:hover {
  background: var(--pop-dim);
  border: 2px solid transparent;
  background-clip: content-box;
}

.root-block {
  border: var(--pop-border-w, 2px) solid var(--pop-ink);
  border-radius: var(--pop-radius-sm, 8px);
  background: var(--pop-surface);
  padding: 4px 2px 6px;
  margin: 0 0 10px;
  box-sizing: border-box;
}

.root-block:last-child {
  margin-bottom: 4px;
}

.root-block.is-height-animating {
  overflow: hidden;
}

.row {
  display: grid;
  /* handle | toggle | title-cell | meta | done */
  grid-template-columns: var(--handle-w) var(--toggle-w) minmax(0, 1fr) auto auto;
  align-items: center;
  column-gap: 4px;
  min-height: var(--row-h);
  padding: 0 8px 0 2px;
  border-radius: 8px;
  margin: 0;
  position: relative;
  line-height: 1.35;
}

/* 葉でトグル／「・」が無いときだけ列を減らす（期限順の葉は・用の列を残す）
   アーカイブは常にトグル列を確保して深さ字下げと揃える */
.row.is-leaf:not(:has(.toggle)) {
  grid-template-columns: var(--handle-w) minmax(0, 1fr) auto auto;
}

/* トップレベルは .root-block で囲む。ブロック内の先頭行余白は不要 */
.row.is-root {
  margin-top: 0;
}

.row.is-root .title-input {
  font-size: 0.94rem;
  font-weight: 800;
}

/* 期限順はフラットだが、子要素相当の行間・字下げで揃える */
.row.is-due-flat {
  margin-top: 0;
  min-height: calc(var(--row-h) + 6px);
  padding-top: 3px;
  padding-bottom: 3px;
}

.row.is-due-flat .title-input,
.row.is-due-flat .title-mirror,
.row.is-leaf.is-due-flat .title-input,
.row.is-leaf.is-due-flat .title-mirror {
  font-size: 0.94rem;
  font-weight: 700;
}

.row.is-due-flat + .row.is-due-flat {
  margin-top: 2px;
}

.row[data-depth] {
  padding-left: calc(2px + var(--depth, 0) * var(--indent));
}

body.is-title-wrap .row {
  align-items: start;
}

body.is-title-wrap .row-meta,
body.is-title-wrap .done-btn {
  /* 折り返し時も行全体の中央に置く（先頭に張り付かせない） */
  align-self: center;
}

body.is-title-wrap .drag-handle,
body.is-title-wrap .toggle {
  align-self: start;
  margin-top: 0.2em;
}

.row.is-selected {
  background: var(--pop-selected);
}

.row.is-range {
  background: var(--pop-range);
}

.row.is-selected.is-range {
  background: var(--pop-selected-range);
}

.row:hover {
  background: var(--pop-row-hover);
}

.row.is-dragging {
  opacity: 0.45;
}

.mobile-drag-ghost {
  position: fixed !important;
  z-index: 100;
  pointer-events: none !important;
  margin: 0 !important;
  opacity: 1 !important;
  box-shadow: 0 14px 30px color-mix(in srgb, var(--pop-ink) 24%, transparent);
  transform-origin: center;
}

.row.is-flipping {
  z-index: 1;
  will-change: transform;
}

/* 完了・削除の退場 / 戻す・復活の入場（左右対称） */
.row.is-exit {
  animation: row-exit 0.2s ease forwards;
  pointer-events: none;
}

.row.is-enter {
  animation: row-enter 0.2s ease both;
}

/* 折りたたみ展開用（完了の左右スライドとは別） */
.row.is-expand-enter {
  animation: row-expand-enter 0.16s ease both;
}

@keyframes row-exit {
  from {
    opacity: 1;
    transform: none;
  }
  to {
    opacity: 0;
    transform: translateX(14px);
  }
}

@keyframes row-enter {
  from {
    opacity: 0;
    transform: translateX(14px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes row-expand-enter {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.view {
  animation: none;
}

.view.is-active:not([hidden]) {
  animation: view-in 0.16s ease both;
}

@keyframes view-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.row.is-drop-before::before,
.row.is-drop-after::after {
  content: "";
  position: absolute;
  left: calc(2px + var(--handle-w) + var(--drop-bar-depth, var(--depth, 0)) * var(--indent));
  right: 8px;
  height: 3px;
  background: var(--pop-accent);
  border-radius: 2px;
  pointer-events: none;
  z-index: 2;
}

.row.is-drop-before::before {
  top: -1px;
}

.row.is-drop-after::after {
  bottom: -1px;
}

.row.is-drop-into {
  background: var(--pop-due-soft);
  outline: 2px solid var(--pop-accent);
  outline-offset: -2px;
}

.row.is-context-parent .title-input {
  color: var(--pop-dim);
}

.drag-handle {
  width: var(--handle-w);
  height: 22px;
  border: 0;
  background: transparent;
  color: var(--pop-muted);
  cursor: grab;
  font-size: 0.8rem;
  line-height: 1;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
  -webkit-user-drag: none;
  user-select: none;
}

.drag-handle:active {
  cursor: grabbing;
}

body.is-pointer-dragging {
  user-select: none;
  -webkit-user-select: none;
  cursor: grabbing;
}

body.is-pointer-dragging .outline {
  touch-action: none;
}

.toggle {
  width: var(--toggle-w);
  height: 22px;
  border: 0;
  background: transparent;
  color: var(--pop-dim);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-size: 0.68rem;
  font-weight: 800;
  cursor: pointer;
  border-radius: 6px;
}

.toggle:hover {
  background: var(--pop-ink-soft);
  color: var(--pop-ink);
}

.leaf-mark {
  cursor: default;
  pointer-events: none;
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1;
}

.leaf-mark:hover {
  background: transparent;
  color: var(--pop-dim);
}

.toggle-spacer {
  pointer-events: none;
  visibility: hidden;
}

/* プレーンテキスト表示: 本文は `- ` 込み、▼は左ガター（Docs風） */
body.is-plain-text .main-pane,
body.is-plain-text .view.is-active {
  background: var(--pop-surface);
}

body.is-plain-text .outline {
  --indent: 1.25em;
  --toggle-w: 18px;
  --handle-w: 14px;
  --row-h: 1.55em;
  --plain-gutter: calc(var(--handle-w) + var(--toggle-w) + 4px);
  font-family: ui-monospace, "Cascadia Code", "Source Han Code JP", Consolas, monospace;
  font-size: 0.9rem;
  line-height: 1.55;
  padding: 12px 16px 28px 8px;
  user-select: text;
  background: var(--pop-surface);
}

body.is-plain-text .root-block {
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 0;
  margin: 0;
}

body.is-plain-text .row.is-plain-row {
  grid-template-columns: var(--handle-w) var(--toggle-w) minmax(0, 1fr) auto auto;
  align-items: center;
  border-radius: 0;
  min-height: var(--row-h);
  padding: 0 4px 0 0;
  column-gap: 2px;
  /* 字下げは本文側だけ。ガター（▼）は左に固定 */
  padding-left: 0 !important;
}

body.is-plain-text .row.is-plain-row[data-depth] {
  padding-left: 0 !important;
}

body.is-plain-text .row:hover {
  background: transparent;
}

body.is-plain-text .row.is-selected,
body.is-plain-text .row.is-range,
body.is-plain-text .row.is-selected.is-range {
  background: color-mix(in srgb, var(--pop-accent) 14%, transparent);
}

body.is-plain-text .plain-text-line {
  display: flex;
  align-items: center;
  align-self: center;
  gap: 0;
  min-width: 0;
  padding-left: calc(var(--depth, 0) * var(--indent));
  font: inherit;
  line-height: inherit;
}

body.is-plain-text .plain-prefix {
  flex: 0 0 auto;
  white-space: pre;
  font: inherit;
  font-weight: 500;
  line-height: inherit;
  color: var(--pop-ink);
  user-select: none;
  pointer-events: none;
}

body.is-plain-text .plain-text-line .title-grow {
  flex: 1 1 auto;
  min-width: 0;
  max-width: none;
}

body.is-plain-text .plain-text-line .title-stack {
  flex: 1 1 auto;
  min-width: 0;
  max-width: none;
}

body.is-plain-text .row.is-root .title-input,
body.is-plain-text .row.is-root .title-mirror,
body.is-plain-text .row.is-zoom-root .title-input {
  font-size: inherit;
  font-weight: 500;
}

body.is-plain-text .title-input,
body.is-plain-text .title-mirror {
  font-family: inherit;
  font-weight: 500;
  font-size: inherit;
  line-height: inherit;
  padding: 0;
  caret-color: var(--pop-ink);
}

body.is-plain-text .title-input::placeholder {
  color: var(--pop-muted);
  opacity: 0.7;
}

body.is-plain-text .drag-handle {
  opacity: 0;
  color: var(--pop-muted);
  align-self: center;
}

body.is-plain-text .row:hover .drag-handle,
body.is-plain-text .row.is-selected .drag-handle {
  opacity: 1;
}

/* ガターの ▼/▶ — 本文の外、ホバーで強調 */
body.is-plain-text .toggle {
  width: var(--toggle-w);
  height: auto;
  align-self: center;
  font-size: 0.62rem;
  font-weight: 700;
  line-height: inherit;
  color: var(--pop-muted);
  border-radius: 2px;
  opacity: 0.55;
}

body.is-plain-text .row:hover .toggle,
body.is-plain-text .row.is-selected .toggle {
  opacity: 1;
  color: var(--pop-dim);
}

body.is-plain-text .toggle:hover {
  background: var(--pop-ink-soft);
  color: var(--pop-ink);
  opacity: 1;
}

body.is-plain-text .toggle-spacer {
  opacity: 0;
}

body.is-plain-text .progress-wrap {
  display: none;
}

body.is-plain-text .done-btn {
  font-size: 0.68rem;
  border-radius: 4px;
  padding: 0.15em 0.55em;
  box-shadow: none;
}

body.is-plain-text .row-meta {
  opacity: 0.85;
}

body.is-plain-text .date-stamp {
  /* 本文の mono を継承させず、通常と同じ UI フォントで揃える */
  font-family: var(--pop-font);
}

.title-input {
  width: 100%;
  border: 0 !important;
  box-shadow: none !important;
  outline: none !important;
  background: transparent !important;
  padding: 3px 4px;
  border-radius: 0;
  min-width: 0;
  font-weight: 700;
  font-size: 0.94rem;
  line-height: 1.35;
}

.title-input:focus {
  outline: none !important;
  box-shadow: none !important;
  background: transparent !important;
}

.row-meta {
  display: flex;
  align-items: center;
  align-self: center;
  gap: 6px;
  color: var(--pop-dim);
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
  padding-left: 6px;
  font-variant-numeric: tabular-nums;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  border: 2px solid var(--pop-ink);
  border-radius: 999px;
  padding: 0 8px;
  font-size: 0.68rem;
  font-weight: 800;
  background: var(--pop-marker);
  color: var(--pop-ink);
}

.status-pill.is-open {
  background: var(--pop-status-open-bg);
  color: var(--pop-dim);
}

.done-btn {
  opacity: 0;
  pointer-events: none;
  align-self: center;
  border: 2px solid var(--pop-ink);
  background: var(--pop-accent);
  color: var(--pop-on-accent);
  border-radius: 999px;
  padding: 0.2em 0.75em;
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1.2;
  white-space: nowrap;
  flex-shrink: 0;
  box-shadow: 2px 2px 0 var(--pop-shadow-ink-18);
  transition: opacity 0.1s ease;
}

.row:hover .done-btn,
.row.is-selected .done-btn,
.done-btn:focus-visible {
  opacity: 1;
  pointer-events: auto;
}

.done-btn.is-restore {
  background: var(--pop-surface);
  color: var(--pop-ink);
}

.detail-pane {
  margin: 12px;
  padding: 16px !important;
  overflow: auto;
  min-height: auto;
  align-self: stretch;
}

.detail-pane.is-empty {
  align-self: start;
  padding: 10px 14px !important;
  margin: 12px;
}

.detail-empty {
  color: var(--pop-dim);
  margin: 0;
  line-height: 1.4;
  font-weight: 700;
  font-size: 0.84rem;
}

.detail-empty p {
  margin: 0;
}

.detail-empty[hidden],
.detail-body[hidden] {
  display: none !important;
}

.detail-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 100%;
}

.detail-title {
  width: 100%;
  font-size: 1.05rem;
  font-weight: 800;
  border: 0 !important;
  box-shadow: none !important;
  outline: none !important;
  background: transparent !important;
  border-radius: 8px;
  padding: 4px 2px;
}

.detail-title:focus {
  outline: none !important;
  box-shadow: none !important;
  background: transparent !important;
}

.detail-meta {
  margin-top: 8px;
  color: var(--pop-dim);
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
}

.field-label {
  font-size: 0.8rem;
  color: var(--pop-dim);
  font-weight: 800;
}

.detail-note {
  flex: 1;
  min-height: 220px;
  border: 2px solid var(--pop-ink);
  border-radius: 12px;
  padding: 12px;
  resize: vertical;
  font-size: 0.9rem;
  line-height: 1.55;
  font-weight: 500;
}

.detail-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.mobile-move-actions {
  display: none;
  gap: 6px;
}

.mobile-move-actions[hidden] {
  display: none !important;
}

.mobile-move-actions .pop-btn {
  min-width: 0;
  flex: 1 1 0;
}

.empty-state {
  color: var(--pop-dim);
  padding: 28px 16px;
  line-height: 1.6;
  font-weight: 700;
}

.toast-host {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  max-width: min(92vw, 520px);
  width: max-content;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--pop-surface);
  border: 2px solid var(--pop-ink);
  border-radius: 999px;
  box-shadow: var(--pop-shadow-hard);
  padding: 10px 14px 10px 18px;
  font-weight: 800;
  animation: toast-in 0.2s ease both;
  max-width: 100%;
  white-space: nowrap;
}

.toast-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 1 1 auto;
}

.toast.is-leaving {
  animation: toast-out 0.22s ease forwards;
}

.toast button {
  border: 2px solid var(--pop-ink);
  background: var(--pop-marker);
  color: var(--pop-ink);
  border-radius: 999px;
  padding: 4px 12px;
  font-weight: 800;
  white-space: nowrap;
  flex-shrink: 0;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes toast-out {
  from {
    opacity: 1;
    transform: none;
  }
  to {
    opacity: 0;
    transform: translateY(10px);
  }
}

.detail-sheet-handle {
  display: none;
}

.detail-sheet-backdrop {
  display: none;
}

@media (max-width: 900px) {
  body {
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
  }

  .detail-pane,
  .detail-pane * {
    user-select: text;
    -webkit-user-select: text;
    -webkit-touch-callout: default;
  }

  .detail-pane button,
  .detail-sheet-handle {
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
  }

  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr);
  }

  .main-pane {
    border-right: 0;
    border-bottom: 0;
  }

  .detail-sheet-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 40;
    background: color-mix(in srgb, var(--pop-ink) 28%, transparent);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
  }

  .detail-sheet-backdrop.is-visible {
    opacity: 1;
    pointer-events: auto;
  }

  .detail-sheet-backdrop[hidden] {
    display: none !important;
  }

  .detail-pane {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 45;
    width: auto;
    margin: 0;
    padding: 0 16px 16px !important;
    max-height: min(88vh, 720px);
    border-radius: 18px 18px 0 0;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
    box-shadow: 0 -6px 0 color-mix(in srgb, var(--pop-ink) 12%, transparent);
    transform: translateY(110%);
    transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
    overflow: hidden;
    align-self: auto;
    pointer-events: none;
  }

  .detail-pane.is-sheet-peek,
  .detail-pane.is-sheet-expanded {
    pointer-events: auto;
    transform: translateY(0);
  }

  .detail-pane.is-sheet-peek {
    max-height: none;
    height: auto;
    overflow: hidden;
  }

  .detail-pane.is-sheet-expanded {
    max-height: min(88vh, 720px);
    height: min(88vh, 720px);
    overflow: auto;
  }

  .detail-pane.is-sheet-dragging {
    transition: none;
  }

  .detail-pane.is-empty,
  .detail-pane.is-sheet-closed {
    transform: translateY(110%);
    pointer-events: none;
  }

  .detail-empty {
    display: none !important;
  }

  .detail-sheet-handle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    margin: 0 -16px;
    padding: 10px 16px 6px;
    border: 0;
    background: transparent;
    color: var(--pop-dim);
    cursor: grab;
    touch-action: none;
  }

  .detail-sheet-handle[hidden] {
    display: none !important;
  }

  .detail-sheet-handle-bar {
    display: block;
    width: 42px;
    height: 5px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--pop-ink) 28%, transparent);
  }

  .detail-pane.is-sheet-peek .detail-meta,
  .detail-pane.is-sheet-peek .detail-note-label,
  .detail-pane.is-sheet-peek .detail-note,
  .detail-pane.is-sheet-peek #btn-zoom-in {
    display: none !important;
  }

  .detail-pane.is-sheet-peek .detail-body {
    min-height: 0;
    gap: 8px;
  }

  .detail-pane.is-sheet-peek .detail-actions {
    margin-top: 2px;
  }

  .detail-pane.is-sheet-peek .mobile-move-actions,
  .detail-pane.is-sheet-expanded .mobile-move-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .detail-pane.is-sheet-expanded .detail-note {
    min-height: 140px;
    resize: none;
  }

  .detail-pane.is-sheet-expanded .detail-body {
    min-height: 0;
    flex: 1;
  }

  .topbar {
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
  }

  .brand-mark {
    font-size: 1.15rem;
  }

  .tabs {
    padding: 2px;
    gap: 2px;
  }

  .tab {
    padding: 4px 10px;
    font-size: 0.72rem;
  }

  .topbar-menu-btn {
    display: inline-flex;
  }

  .topbar-actions.tool-panel--topbar {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    left: auto;
    z-index: 50;
    min-width: 168px;
    max-width: min(92vw, 240px);
    padding: 6px;
    background: var(--pop-surface);
    border: 2px solid var(--pop-ink);
    border-radius: 12px;
    box-shadow: var(--pop-shadow);
    display: none !important;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
  }

  .topbar-end.is-open > .topbar-actions.tool-panel--topbar {
    display: flex !important;
  }

  .topbar-actions .tool-pop {
    width: 100%;
  }

  .topbar-actions .topbar-action-btn {
    width: 100%;
    height: auto;
    min-height: 36px;
    justify-content: flex-start;
    gap: 10px;
    padding: 6px 10px;
    border-radius: 8px;
  }

  .topbar-actions .topbar-action-label {
    display: inline;
    font-size: 0.84rem;
    font-weight: 800;
    color: var(--pop-ink);
    line-height: 1.2;
  }

  .topbar-actions .topbar-lang-pop {
    width: 100%;
  }

  .topbar-actions .tool-panel--lang {
    position: static;
    min-width: 0;
    max-width: none;
    margin-top: 2px;
    padding: 0;
    border: 0;
    box-shadow: none;
    background: transparent;
    display: none;
  }

  .topbar-actions .topbar-lang-pop.is-open > .tool-panel--lang {
    display: flex;
    flex-direction: column;
    gap: 2px;
  }

  .topbar-actions .lang-option {
    padding: 6px 10px 6px 36px;
  }

  /* Mobile row chrome: hide desktop meta/done; keep handle for DnD; dates under title.
     Always pin handle/▼/progress to the first text line — no single/multi detection. */
  .app {
    --handle-w: 24px;
    --toggle-w: 20px;
    --mobile-row-line: 30px;
  }

  .row,
  body.is-plain-text .row,
  body.is-title-wrap .row {
    grid-template-columns: var(--handle-w) var(--toggle-w) minmax(0, 1fr) !important;
    align-items: start !important;
    min-height: var(--mobile-row-line);
    padding-top: 1px;
    padding-bottom: 1px;
    touch-action: pan-y;
    user-select: none;
    -webkit-user-select: none;
  }

  .row.is-leaf:not(:has(.toggle)),
  body.is-plain-text .row.is-leaf:not(:has(.toggle)) {
    grid-template-columns: var(--handle-w) minmax(0, 1fr) !important;
  }

  .drag-handle,
  .toggle,
  body.is-title-wrap .drag-handle,
  body.is-title-wrap .toggle,
  body.is-plain-text .drag-handle,
  body.is-plain-text .toggle {
    box-sizing: border-box;
    display: grid !important;
    place-items: center;
    height: var(--mobile-row-line) !important;
    min-height: var(--mobile-row-line) !important;
    margin: 0 !important;
    padding: 0 !important;
    align-self: start !important;
    border: 0;
    background: transparent;
    line-height: 1 !important;
    font-size: 0.72rem;
    font-weight: 800;
    color: var(--pop-ink);
  }

  .drag-handle,
  body.is-title-wrap .drag-handle,
  body.is-plain-text .drag-handle {
    position: relative;
    width: var(--handle-w);
    touch-action: none;
    opacity: 1 !important;
    visibility: hidden !important;
    pointer-events: none !important;
    /* ⠿ sits high in the em-box; nudge to match ▼ */
    translate: 0 1px;
  }

  .drag-handle::after {
    content: "";
    position: absolute;
    inset: -8px -4px;
  }

  .toggle,
  body.is-title-wrap .toggle,
  body.is-plain-text .toggle {
    width: var(--toggle-w);
    color: var(--pop-dim);
    translate: 0 0;
  }

  .row-meta,
  .done-btn {
    display: none !important;
  }

  .row-submeta:not([hidden]) {
    display: block;
    margin-top: 0;
    padding: 0 4px 1px;
    font-size: 0.68rem;
    font-weight: 700;
    line-height: 1.25;
    color: var(--pop-dim);
    font-variant-numeric: tabular-nums;
  }

  .row-submeta.is-today {
    color: var(--pop-accent);
  }

  .row-submeta.is-overdue {
    color: var(--pop-danger);
  }

  .row-submeta.is-completed {
    color: var(--pop-ok);
  }

  .title-cell,
  body.is-plain-text .plain-text-line,
  body.is-title-wrap .title-cell,
  body.is-title-wrap .plain-text-line {
    align-items: flex-start !important;
    align-self: start !important;
    min-width: 0;
    width: 100%;
    min-height: var(--mobile-row-line);
  }

  .title-stack,
  .title-cell.has-progress .title-stack,
  body.is-plain-text .plain-text-line .title-stack {
    flex: 1 1 0;
    min-width: 0;
    max-width: 100%;
    justify-content: flex-start;
    overflow: visible;
  }

  .title-cell.has-progress .title-stack {
    max-width: calc(100% - 52px);
  }

  .title-grow {
    min-height: var(--mobile-row-line);
    overflow: visible;
  }

  /* Same line-height for wrap and non-wrap so first line always matches icon box */
  .title-mirror,
  body.is-title-wrap .title-mirror {
    min-height: var(--mobile-row-line);
    padding: 0 4px;
    line-height: var(--mobile-row-line);
    font-size: 16px;
  }

  .title-grow .title-input,
  body.is-title-wrap .title-grow .title-input {
    padding: 0 4px;
    line-height: var(--mobile-row-line);
    font-size: 16px !important;
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
  }

  body.is-title-wrap .title-mirror,
  body.is-title-wrap .title-grow .title-input {
    overflow-wrap: anywhere;
    word-break: break-word;
    white-space: pre-wrap;
  }

  .progress-wrap,
  body.is-title-wrap .progress-wrap {
    margin-top: 0 !important;
    align-self: start !important;
    flex: 0 0 auto;
    height: var(--mobile-row-line);
  }

  body[data-theme="formal"] .detail-pane {
    margin: 0;
    background: var(--pop-surface);
    border-top: 1px solid var(--pop-rule, color-mix(in srgb, var(--pop-ink) 16%, transparent));
    box-shadow: 0 -12px 32px color-mix(in srgb, var(--pop-ink) 10%, transparent);
  }

  body[data-theme="geek"] .detail-pane {
    margin: 0;
  }
}

@media (max-width: 900px) and (prefers-reduced-motion: reduce) {
  .detail-pane,
  .detail-sheet-backdrop {
    transition: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .toast,
  .toast.is-leaving,
  .row.is-exit,
  .row.is-enter,
  .row.is-expand-enter,
  .view.is-active:not([hidden]) {
    animation: none;
  }

  .row.is-flipping {
    transition: none !important;
    transform: none !important;
  }
}

.theme-dialog-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.file-dialog-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.file-dialog-item {
  font-size: 0.92rem;
  padding: 12px 14px;
}

/* Theme switcher */
.tool-panel--theme {
  min-width: 220px;
  max-width: min(92vw, 280px);
  padding: 8px;
  left: auto !important;
  right: 0;
  z-index: 50;
  flex-direction: column;
  gap: 4px;
}

.tool-pop.is-open > .tool-panel--theme:not([hidden]) {
  display: flex;
}

.theme-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: var(--pop-border-w) solid transparent;
  background: transparent;
  text-align: left;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--pop-ink);
  cursor: pointer;
  font-family: inherit;
}

.theme-option:hover {
  background: var(--pop-hover-fill);
}

.theme-option.is-active {
  border-color: var(--pop-ink);
  background: var(--pop-hover-fill);
}

.theme-swatch {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: var(--pop-border-w) solid var(--pop-ink);
  background: linear-gradient(135deg, var(--swatch-a) 0 50%, var(--swatch-b) 50% 100%);
  box-shadow: inset -6px -6px 0 var(--swatch-c);
}

.theme-option-name {
  font-size: 0.86rem;
  font-weight: 800;
  line-height: 1.3;
}

.theme-option[data-theme-id="retro-pop"] .theme-swatch {
  --swatch-a: #fff8ec;
  --swatch-b: #f4604c;
  --swatch-c: #ffd94a;
}

.theme-option[data-theme-id="easygoing"] .theme-swatch {
  --swatch-a: #f6f4ef;
  --swatch-b: #5271ff;
  --swatch-c: #ffe39a;
}

.theme-option[data-theme-id="formal"] .theme-swatch {
  --swatch-a: #f4f2ee;
  --swatch-b: #2a4a6e;
  --swatch-c: #dfe4ea;
}

.theme-option[data-theme-id="geek"] .theme-swatch {
  --swatch-a: #1e1e1e;
  --swatch-b: #3c3c3c;
  --swatch-c: #252526;
}

.theme-option[data-theme-id="calm"] .theme-swatch {
  --swatch-a: #eef3f1;
  --swatch-b: #5a9e8b;
  --swatch-c: #d5ebe3;
}


/* Non-default themes: border/radius from tokens (retro-pop keeps literals above) */
body[data-theme="easygoing"] .app,
body[data-theme="formal"] .app,
body[data-theme="geek"] .app,
body[data-theme="calm"] .app {
  border-left-width: var(--pop-border-w);
  border-right-width: var(--pop-border-w);
}

body[data-theme="easygoing"] .topbar,
body[data-theme="easygoing"] .main-pane,
body[data-theme="easygoing"] .view-tools,
body[data-theme="easygoing"] .help-dialog,
body[data-theme="easygoing"] .tool-panel,
body[data-theme="easygoing"] .tabs,
body[data-theme="formal"] .topbar,
body[data-theme="geek"] .topbar,
body[data-theme="calm"] .topbar,
body[data-theme="formal"] .main-pane,
body[data-theme="geek"] .main-pane,
body[data-theme="calm"] .main-pane,
body[data-theme="formal"] .view-tools,
body[data-theme="geek"] .view-tools,
body[data-theme="calm"] .view-tools,
body[data-theme="formal"] .help-dialog,
body[data-theme="geek"] .help-dialog,
body[data-theme="calm"] .help-dialog,
body[data-theme="formal"] .tool-panel,
body[data-theme="geek"] .tool-panel,
body[data-theme="calm"] .tool-panel,
body[data-theme="formal"] .tabs,
body[data-theme="geek"] .tabs,
body[data-theme="calm"] .tabs {
  border-width: var(--pop-border-w);
}

body[data-theme="easygoing"] .tabs,
body[data-theme="easygoing"] .tab,
body[data-theme="easygoing"] .status-pill,
body[data-theme="easygoing"] .done-btn,
body[data-theme="easygoing"] .filter-chip,
body[data-theme="easygoing"] .toast,
body[data-theme="easygoing"] .date-stamp,
body[data-theme="easygoing"] .tool-icon-btn,
body[data-theme="easygoing"] .menu-item,
body[data-theme="easygoing"] .focus-chip-btn,
body[data-theme="easygoing"] .progress-gauge,
body[data-theme="easygoing"] .root-block,
body[data-theme="easygoing"] .row,
body[data-theme="easygoing"] .theme-option,
body[data-theme="easygoing"] .theme-swatch,
body[data-theme="formal"] .tabs,
body[data-theme="geek"] .tabs,
body[data-theme="calm"] .tabs,
body[data-theme="formal"] .tab,
body[data-theme="geek"] .tab,
body[data-theme="calm"] .tab,
body[data-theme="formal"] .status-pill,
body[data-theme="geek"] .status-pill,
body[data-theme="calm"] .status-pill,
body[data-theme="formal"] .done-btn,
body[data-theme="geek"] .done-btn,
body[data-theme="calm"] .done-btn,
body[data-theme="formal"] .filter-chip,
body[data-theme="geek"] .filter-chip,
body[data-theme="calm"] .filter-chip,
body[data-theme="formal"] .toast,
body[data-theme="geek"] .toast,
body[data-theme="calm"] .toast,
body[data-theme="formal"] .date-stamp,
body[data-theme="calm"] .date-stamp,
body[data-theme="formal"] .tool-icon-btn,
body[data-theme="calm"] .tool-icon-btn,
body[data-theme="formal"] .menu-item,
body[data-theme="calm"] .menu-item,
body[data-theme="formal"] .focus-chip-btn,
body[data-theme="calm"] .focus-chip-btn,
body[data-theme="formal"] .progress-gauge,
body[data-theme="calm"] .progress-gauge,
body[data-theme="formal"] .root-block,
body[data-theme="calm"] .root-block,
body[data-theme="formal"] .row,
body[data-theme="calm"] .row,
body[data-theme="formal"] .theme-option,
body[data-theme="calm"] .theme-option,
body[data-theme="formal"] .theme-swatch,
body[data-theme="calm"] .theme-swatch {
  border-radius: var(--pop-radius-btn);
}

body[data-theme="easygoing"] .root-block,
body[data-theme="easygoing"] .tool-panel,
body[data-theme="easygoing"] .help-dialog,
body[data-theme="formal"] .root-block,
body[data-theme="calm"] .root-block,
body[data-theme="formal"] .tool-panel,
body[data-theme="calm"] .tool-panel,
body[data-theme="formal"] .help-dialog,
body[data-theme="calm"] .help-dialog {
  border-radius: var(--pop-radius-sm);
}

body[data-theme="easygoing"] .title-input,
body[data-theme="easygoing"] .title-mirror,
body[data-theme="easygoing"] .detail-title,
body[data-theme="easygoing"] .detail-note {
  font-weight: 600;
}

body[data-theme="easygoing"] .row.is-root .title-input,
body[data-theme="easygoing"] .row.is-root .title-mirror,
body[data-theme="easygoing"] .row.is-zoom-root .title-input {
  font-weight: 700;
}

body[data-theme="easygoing"] .date-stamp.is-completed .date-stamp-tag {
  background: var(--pop-context-pill);
}

/* Formal: near-square chrome, lighter type, stamp colors aligned */
body[data-theme="formal"] {
  font-weight: var(--pop-weight-body, 400);
  letter-spacing: 0.01em;
}

body[data-theme="formal"] .brand-mark,
body[data-theme="formal"] .pop-title {
  font-weight: 600;
  letter-spacing: 0.02em;
}

body[data-theme="formal"] .tab,
body[data-theme="formal"] .menu-item,
body[data-theme="formal"] .tool-status,
body[data-theme="formal"] .zoom-crumbs,
body[data-theme="formal"] .zoom-crumb,
body[data-theme="formal"] .zoom-sep,
body[data-theme="formal"] .field-label,
body[data-theme="formal"] .filter-chip,
body[data-theme="formal"] .status-pill,
body[data-theme="formal"] .done-btn,
body[data-theme="formal"] .focus-chip-btn,
body[data-theme="formal"] .date-stamp-tag,
body[data-theme="formal"] .date-stamp-val,
body[data-theme="formal"] .progress-label,
body[data-theme="formal"] .row-meta,
body[data-theme="formal"] .detail-meta,
body[data-theme="formal"] .detail-empty,
body[data-theme="formal"] .toast,
body[data-theme="formal"] .theme-option-name,
body[data-theme="formal"] .help-section kbd,
body[data-theme="formal"] .archive-count,
body[data-theme="formal"] .title-input,
body[data-theme="formal"] .title-mirror,
body[data-theme="formal"] .detail-title,
body[data-theme="formal"] .row.is-root .title-input,
body[data-theme="formal"] .row.is-root .title-mirror,
body[data-theme="formal"] .row.is-zoom-root .title-input {
  font-weight: var(--pop-weight-strong, 600);
}

body[data-theme="formal"] .date-stamp {
  border: 0;
  border-radius: var(--pop-radius-sm);
  box-shadow: none;
  background: var(--pop-hover-fill);
}

body[data-theme="formal"] .date-stamp.is-due .date-stamp-tag,
body[data-theme="formal"] .date-stamp.is-completed .date-stamp-tag {
  background: var(--pop-context-pill);
  color: #ffffff;
}

body[data-theme="formal"] .date-stamp.is-due.is-today {
  background: var(--pop-hover-fill);
}

body[data-theme="formal"] .date-stamp.is-due.is-today .date-stamp-tag {
  background: var(--pop-accent);
}

body[data-theme="formal"] .date-stamp.is-due.is-overdue {
  background: var(--pop-danger-soft);
}

body[data-theme="formal"] .date-stamp.is-due.is-overdue .date-stamp-tag {
  background: var(--pop-danger);
}

body[data-theme="formal"] .date-stamp.is-completed {
  background: var(--pop-hover-fill);
}

body[data-theme="formal"] .app {
  border-left-color: transparent;
  border-right-color: transparent;
  background: var(--pop-bg);
}

body[data-theme="formal"] .topbar,
body[data-theme="formal"] .view-tools,
body[data-theme="formal"] .view-toolbar {
  border-bottom-color: var(--pop-divider);
  border-bottom-width: 1px;
}

body[data-theme="formal"] .main-pane {
  border-right-color: var(--pop-divider);
  border-right-width: 1px;
}

body[data-theme="formal"] .tabs,
body[data-theme="formal"] .tab,
body[data-theme="formal"] .tool-icon-btn,
body[data-theme="formal"] .status-pill,
body[data-theme="formal"] .done-btn,
body[data-theme="formal"] .filter-chip,
body[data-theme="formal"] .focus-chip-btn,
body[data-theme="formal"] .toast,
body[data-theme="formal"] .progress-gauge,
body[data-theme="formal"] .root-block,
body[data-theme="formal"] .detail-pane,
body[data-theme="formal"] .detail-note,
body[data-theme="formal"] .help-section kbd,
body[data-theme="formal"] .tool-panel,
body[data-theme="formal"] .help-dialog,
body[data-theme="formal"] .theme-swatch,
body[data-theme="formal"] .zoom-crumb.is-current {
  border-color: transparent;
  border-width: 0;
  box-shadow: none;
}

body[data-theme="formal"] .detail-pane {
  margin: 0;
  background: transparent;
}

body[data-theme="formal"] .detail-pane.is-empty {
  margin: 12px;
  background: transparent;
}

body[data-theme="formal"] .tabs {
  background: transparent;
  padding: 0;
  gap: 0;
}

body[data-theme="formal"] .tab {
  color: var(--pop-dim);
  background: transparent;
}

body[data-theme="formal"] .tab.is-active {
  background: var(--pop-selected);
  color: var(--pop-ink);
}

body[data-theme="formal"] .tool-icon-btn.is-active,
body[data-theme="formal"] .pop-btn.is-active,
body[data-theme="formal"] .filter-chip.is-active,
body[data-theme="formal"] .focus-chip-btn.is-focused {
  background: var(--pop-selected);
  color: var(--pop-ink);
  border-color: transparent;
}

body[data-theme="formal"] .status-pill,
body[data-theme="formal"] .done-btn,
body[data-theme="formal"] .filter-chip,
body[data-theme="formal"] .focus-chip-btn,
body[data-theme="formal"] .toast {
  background: var(--pop-hover-fill);
  color: var(--pop-ink);
}

body[data-theme="formal"] .done-btn {
  background: var(--pop-accent);
  color: var(--pop-on-accent);
}

body[data-theme="formal"] .progress-fill {
  border-radius: 0;
}

body[data-theme="formal"] .progress-gauge {
  border: 1px solid var(--pop-ink);
  border-radius: 2px;
  background: var(--pop-input-fill);
}

body[data-theme="formal"] .theme-option.is-active {
  border-color: transparent;
  background: var(--pop-selected);
}

body[data-theme="formal"] .tool-panel:not(.tool-panel--topbar),
body[data-theme="formal"] .help-dialog {
  background: var(--pop-panel-bg);
  box-shadow: 0 8px 24px rgba(26, 35, 50, 0.14);
}

body[data-theme="formal"] .topbar-actions.tool-panel--topbar {
  background: transparent !important;
  box-shadow: none !important;
}

/* Soft: keep soft radius, but align completed stamp with due stamp family */
body[data-theme="calm"] .date-stamp.is-completed .date-stamp-tag {
  background: var(--pop-context-pill);
  color: #ffffff;
}

body[data-theme="calm"] .date-stamp.is-completed {
  background: var(--pop-input-fill);
}

/* Code theme: square, monochrome, divider-only chrome */
body[data-theme="geek"] .app,
body[data-theme="geek"] .topbar,
body[data-theme="geek"] .main-pane,
body[data-theme="geek"] .view-tools,
body[data-theme="geek"] .view-toolbar,
body[data-theme="geek"] .help-dialog,
body[data-theme="geek"] .tool-panel,
body[data-theme="geek"] .tabs,
body[data-theme="geek"] .tab,
body[data-theme="geek"] .tool-icon-btn,
body[data-theme="geek"] .menu-item,
body[data-theme="geek"] .status-pill,
body[data-theme="geek"] .done-btn,
body[data-theme="geek"] .filter-chip,
body[data-theme="geek"] .focus-chip-btn,
body[data-theme="geek"] .date-stamp,
body[data-theme="geek"] .toast,
body[data-theme="geek"] .progress-gauge,
body[data-theme="geek"] .progress-fill,
body[data-theme="geek"] .root-block,
body[data-theme="geek"] .detail-pane,
body[data-theme="geek"] .detail-note,
body[data-theme="geek"] .detail-title,
body[data-theme="geek"] .theme-option,
body[data-theme="geek"] .theme-swatch,
body[data-theme="geek"] .help-section kbd,
body[data-theme="geek"] .row {
  border-radius: 0;
  box-shadow: none;
}

body[data-theme="geek"] .app {
  border-left-color: transparent;
  border-right-color: transparent;
  background: var(--pop-bg);
}

body[data-theme="geek"] .topbar,
body[data-theme="geek"] .view-tools,
body[data-theme="geek"] .view-toolbar {
  border-bottom-color: var(--pop-divider);
  border-bottom-width: 1px;
}

body[data-theme="geek"] .main-pane {
  border-right-color: var(--pop-divider);
  border-right-width: 1px;
}

body[data-theme="geek"] .tabs,
body[data-theme="geek"] .tab,
body[data-theme="geek"] .tool-icon-btn,
body[data-theme="geek"] .status-pill,
body[data-theme="geek"] .done-btn,
body[data-theme="geek"] .filter-chip,
body[data-theme="geek"] .focus-chip-btn,
body[data-theme="geek"] .toast,
body[data-theme="geek"] .progress-gauge,
body[data-theme="geek"] .root-block,
body[data-theme="geek"] .detail-pane,
body[data-theme="geek"] .detail-note,
body[data-theme="geek"] .help-section kbd,
body[data-theme="geek"] .tool-panel,
body[data-theme="geek"] .help-dialog,
body[data-theme="geek"] .theme-swatch,
body[data-theme="geek"] .zoom-crumb.is-current {
  border-color: transparent;
  border-width: 0;
  box-shadow: none;
}

body[data-theme="geek"] .progress-gauge {
  border: 1px solid var(--pop-ink-mid);
  border-radius: 0;
  background: var(--pop-input-fill);
}

body[data-theme="geek"] .detail-pane {
  margin: 0;
  background: transparent;
}

body[data-theme="geek"] .detail-pane.is-empty {
  margin: 12px;
  background: transparent;
}

body[data-theme="geek"] .tabs {
  background: transparent;
  padding: 0;
  gap: 0;
}

body[data-theme="geek"] .tab {
  color: var(--pop-dim);
  background: transparent;
}

body[data-theme="geek"] .tab.is-active {
  background: var(--pop-selected);
  color: var(--pop-ink);
}

body[data-theme="geek"] .tool-icon-btn.is-active,
body[data-theme="geek"] .pop-btn.is-active,
body[data-theme="geek"] .filter-chip.is-active,
body[data-theme="geek"] .focus-chip-btn.is-focused {
  background: var(--pop-selected);
  color: var(--pop-ink);
  border-color: transparent;
}

body[data-theme="geek"] .status-pill,
body[data-theme="geek"] .done-btn,
body[data-theme="geek"] .filter-chip,
body[data-theme="geek"] .focus-chip-btn,
body[data-theme="geek"] .toast {
  background: var(--pop-hover-fill);
  color: var(--pop-ink);
  box-shadow: none;
}

body[data-theme="geek"] {
  font-weight: var(--pop-weight-body, 400);
}

body[data-theme="geek"] .brand-mark,
body[data-theme="geek"] .pop-title,
body[data-theme="geek"] .tab,
body[data-theme="geek"] .menu-item,
body[data-theme="geek"] .title-input,
body[data-theme="geek"] .title-mirror,
body[data-theme="geek"] .detail-title,
body[data-theme="geek"] .detail-empty,
body[data-theme="geek"] .date-stamp-tag,
body[data-theme="geek"] .date-stamp-val,
body[data-theme="geek"] .status-pill,
body[data-theme="geek"] .done-btn,
body[data-theme="geek"] .filter-chip,
body[data-theme="geek"] .focus-chip-btn,
body[data-theme="geek"] .theme-option-name,
body[data-theme="geek"] .row.is-root .title-input,
body[data-theme="geek"] .row.is-root .title-mirror,
body[data-theme="geek"] .row.is-zoom-root .title-input {
  font-weight: var(--pop-weight-strong, 500);
}

body[data-theme="geek"] .theme-option.is-active {
  border-color: transparent;
  background: var(--pop-selected);
}

body[data-theme="geek"] .theme-swatch {
  background: var(--swatch-a);
  box-shadow: inset -8px 0 0 var(--swatch-b);
}

body[data-theme="geek"] .tool-panel,
body[data-theme="geek"] .help-dialog {
  background: var(--pop-panel-bg);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

body[data-theme="geek"] .date-stamp {
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: var(--pop-hover-fill);
  overflow: hidden;
}

body[data-theme="geek"] .date-stamp-tag,
body[data-theme="geek"] .date-stamp.is-due .date-stamp-tag,
body[data-theme="geek"] .date-stamp.is-due.is-today .date-stamp-tag,
body[data-theme="geek"] .date-stamp.is-due.is-overdue .date-stamp-tag,
body[data-theme="geek"] .date-stamp.is-completed .date-stamp-tag {
  background: var(--pop-marker);
  color: var(--pop-dim);
}

body[data-theme="geek"] .date-stamp.is-due.is-today,
body[data-theme="geek"] .date-stamp.is-due.is-overdue,
body[data-theme="geek"] .date-stamp.is-completed {
  background: var(--pop-hover-fill);
}
