:root {
  color-scheme: light;
  --ground: #f8f8f2;
  --ink: #24372d;
  --muted: #586c60;
  --paper: #eef0e9;
  --accent: #345f4b;
  --accent-ink: #284b3c;
  --soft: #e8ede3;
  --track: #edefe8;
  --selection: #dce8dc;
  --top: #a7bfae;
  --middle: #c3d4c5;
  --bottom: #e0e9de;
  --inside: #223a2c;
  --inside-muted: #435b4d;
  --top-muted: #394f43;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
  font-synthesis: none;
  text-size-adjust: 100%;
  -webkit-text-size-adjust: 100%;
}

[data-tower="execution"] {
  --accent: #465f79;
  --accent-ink: #304a63;
  --soft: #e7edf0;
  --track: #eef0ed;
  --selection: #dce6ed;
  --top: #aabccd;
  --middle: #c6d3de;
  --bottom: #e0e8ee;
  --inside: #233849;
  --inside-muted: #3b5161;
  --top-muted: #344c5e;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; color: var(--ink); background: var(--ground); line-height: 1.5; }
h1, h2, p { margin: 0; }
a { color: inherit; }
button, textarea, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .55; cursor: default; }
button, a, summary, label { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid currentColor; outline-offset: 3px; }
h1:focus { outline: none; }
svg { display: block; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.app-shell {
  max-width: 454px;
  margin: 0 auto;
  padding: max(28px, calc(env(safe-area-inset-top) + 12px)) max(22px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(22px, env(safe-area-inset-left));
}

.app-shell:has(> .pyramid) { max-width: 548px; }

.home-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 22px; }
.home-header h1 { font-size: 31px; letter-spacing: .035em; line-height: 1.3; font-weight: 700; }
.home-header time { display: block; margin-top: 5px; color: var(--muted); font-size: 13px; letter-spacing: .02em; }
.icon-button { display: grid; place-items: center; width: 44px; height: 44px; flex: none; border: 0; border-radius: 50%; color: var(--accent-ink); background: var(--soft); }
.icon-button svg { width: 21px; height: 21px; }

.tower-switch { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px; padding: 3px; border-radius: 15px; background: var(--track); }
.tower-switch a { display: grid; place-items: center; min-height: 44px; border-radius: 12px; text-decoration: none; font-size: 15px; font-weight: 550; color: var(--muted); }
.tower-switch a[aria-current] { background: var(--selection); color: var(--accent-ink); font-weight: 700; }

.pyramid { height: clamp(490px, 127vw, 590px); position: relative; margin: 21px -18px 0; isolation: isolate; animation: settle .18s ease-out both; }
.pyramid-shape { position: absolute; width: 100%; height: 100%; inset: 0; pointer-events: none; }
.top-fill { fill: var(--top); }
.middle-fill { fill: var(--middle); }
.bottom-fill { fill: var(--bottom); }
.pyramid-divider { stroke: var(--ground); stroke-opacity: .55; stroke-width: 1; }
.tier { position: absolute; width: 100%; left: 0; display: flex; flex-direction: column; align-items: center; color: var(--inside); pointer-events: none; }
.tier h2 { font-size: calc(11px + var(--support-size-bump, 0px)); font-weight: 400; line-height: 17px; letter-spacing: .14em; color: var(--inside-muted); }
.tier-1 { top: calc(var(--first-cut) - clamp(112px, 18vw, 138px)); }
.tier-1 h2 { color: var(--top-muted); }
.tier-2 { top: calc(var(--first-cut) + 4px); }
.tier-3 { top: calc(var(--second-cut) + 8px); }
.tier-entries { display: grid; justify-items: center; margin-top: 5px; }
.tier-1 .tier-entries { margin-top: 9px; }
.tier-2 .tier-entries { margin-top: 2px; }
.entry-link { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 44px; min-width: 44px; padding: 3px 8px; border-radius: 10px; text-align: center; text-decoration: none; pointer-events: auto; }
.entry-name { display: flex; flex-direction: column; gap: 4px; align-items: inherit; position: relative; }
.entry-title { font-size: calc(var(--title-size, 17px) + var(--title-size-bump, 0px)); font-weight: var(--title-weight, 600); line-height: 1.28; text-decoration: underline color-mix(in srgb, currentColor 16%, transparent); text-decoration-thickness: 1px; text-underline-offset: 3px; transition: text-decoration-color .14s ease; }
.entry-lead, .entry-note { color: var(--inside-muted); color: color-mix(in srgb, var(--inside-muted) 85%, var(--inside)); font-size: calc(var(--note-size, 13px) + var(--support-size-bump, 0px)); font-weight: 400; line-height: 1.3; }
.tier-1 .entry-lead { color: var(--top-muted); color: color-mix(in srgb, var(--top-muted) 85%, var(--inside)); }
.entry-note { margin-top: 4px; }
.entry-state { position: absolute; top: 0; left: calc(100% + 5px); min-width: 11px; text-align: center; font-size: 10px; line-height: 13px; font-variant-numeric: tabular-nums; color: var(--accent-ink); }
.tier-1 .entry-state { top: calc(100% + 1px); left: 50%; transform: translateX(-50%); }

[data-tower="thought"] .tier-entries { row-gap: 5px; }
[data-tower="thought"] .tier-1 .entry-link { --title-size: 21px; min-height: 73px; }
[data-tower="thought"] .tier-2 .tier-entries { row-gap: clamp(7px, 1.6vw, 15px); }
[data-tower="thought"] .tier-3 .tier-entries { row-gap: clamp(9px, 2.2vw, 20px); margin-top: 4px; }
[data-tower="thought"] .tier-3 .entry-link { padding-block: 1px; }
[data-entry="passing"] { --title-size: 22px; }
[data-entry="boundaries"] { --title-size: 18px; }
[data-entry="self"] { --title-size: 16px; }

[data-layout="a"] [data-entry="my-work"] { margin-inline-end: 20px; }
[data-layout="a"] [data-entry="boundaries"] { margin-inline-start: 35px; }
[data-layout="a"] [data-entry="boundaries"] .entry-lead { order: 1; }
[data-layout="a"] [data-entry="boundaries"] .entry-state { top: 2px; }
[data-layout="a"] [data-entry="passing"] { margin-inline-end: 40px; }
[data-layout="a"] [data-entry="self"] { margin-inline-start: 22px; }
[data-layout="a"] [data-entry="self"] .entry-name { flex-direction: row; align-items: baseline; }

[data-tower="thought"] [data-layout="b"] .tier-2 .tier-entries { width: 51%; }
[data-tower="thought"] [data-layout="b"] .tier-3 .tier-entries { width: 73%; margin-top: 1px; row-gap: clamp(2px, calc(2vw - 5px), 12px); }
[data-tower="thought"] [data-layout="b"] .tier:not(.tier-1) .entry-link:first-child { justify-self: start; align-items: flex-start; text-align: start; }
[data-tower="thought"] [data-layout="b"] .tier:not(.tier-1) .entry-link:last-child { justify-self: end; align-items: flex-end; text-align: end; }
[data-tower="thought"] [data-layout="b"] .tier:not(.tier-1) .entry-link:last-child .entry-state { left: auto; right: calc(100% + 5px); }
[data-layout="b"] [data-entry="self"] .entry-note { --note-size: 12px; }

.entry-row { display: flex; justify-content: center; gap: 10px; }
.entry-row + .entry-row { --title-size: 14px; --title-weight: 400; }
.entry-row + .entry-row .entry-title { color: var(--inside-muted); }
[data-tower="execution"] .tier-1 .tier-entries { margin-top: 0; row-gap: clamp(7px, 1.75vw, 13px); }
[data-tower="execution"] .tier-1 .entry-link { padding-inline: 1px; }
[data-tower="execution"] .tier-1 .entry-row { column-gap: 2px; }
[data-tower="execution"] .tier-1 .entry-row + .entry-row { margin-inline-start: 7px; }
[data-tower="execution"] .tier-1 .entry-row + .entry-row .entry-title { color: var(--top-muted); }
[data-tower="execution"] .tier-2 .tier-entries { margin-top: 6px; row-gap: clamp(6px, 1.6vw, 12px); }
[data-tower="execution"] .tier-2 .entry-link { min-width: 82px; }
[data-tower="execution"] .tier-2 .entry-row { column-gap: clamp(18px, 5vw, 36px); }
[data-tower="execution"] .tier-3 .tier-entries { margin-top: 8px; row-gap: clamp(9px, 2.2vw, 17px); }
[data-tower="execution"] .tier-3 .entry-row { column-gap: clamp(20px, 5.3vw, 42px); }
[data-tower="execution"] .entry-state { display: grid; place-items: center; height: 13px; top: 3px; }
[data-tower="execution"] .tier-1 .entry-state { top: calc(100% - 1px); }
[data-tower="execution"] .entry-state svg { width: 11px; height: 11px; }
.progress-dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }

[data-tower="execution"] [data-layout="a"] .tier-3 .entry-row:first-child { --title-size: 18px; }
[data-tower="execution"] [data-layout="b"] .entry-row + .entry-row { --title-size: 15px; }
[data-tower="execution"] [data-layout="b"] .tier-1 .entry-row + .entry-row { --title-size: 14px; }
[data-tower="execution"] [data-layout="b"] .tier-2 .tier-entries { width: min(58%, 298px); margin-inline-start: 24px; }
[data-tower="execution"] [data-layout="b"] .tier-2 .entry-row { display: grid; width: 100%; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(21px, 5vw, 32px); }
[data-tower="execution"] [data-layout="b"] .tier-2 .entry-link { align-items: flex-start; min-width: 44px; text-align: start; }
[data-tower="execution"] [data-layout="b"] .tier-3 .entry-row:first-child { --title-size: 18px; column-gap: clamp(25px, 6.5vw, 48px); }
[data-tower="execution"] [data-layout="b"] .tier-3 .entry-row + .entry-row { margin-inline-start: 26px; }

.home-footer { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: baseline; gap: 12px; margin-top: 15px; color: var(--muted); font-size: 12px; line-height: 1.5; font-variant-numeric: tabular-nums; }
.home-footer p:last-child { text-align: end; }
.tower-summary strong { margin-inline-end: .28em; font-weight: 550; }

.detail-nav { margin: -9px 0 13px -7px; }
.back-link { display: inline-flex; min-height: 44px; align-items: center; gap: 4px; border-radius: 8px; text-decoration: none; color: var(--accent-ink); font-weight: 650; font-size: 14px; }
.back-link svg { width: 20px; height: 20px; }
.entry-heading-meta { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 13px; }
.detail-meta.is-active { color: var(--accent-ink); }
.detail-meta.is-active::before { content: ''; display: inline-block; width: 5px; height: 5px; margin-inline-end: 6px; border-radius: 50%; vertical-align: .17em; background: currentColor; }
.entry-header h1 { margin-top: 8px; font-size: 30px; font-weight: 700; line-height: 1.37; overflow-wrap: anywhere; }
.entry-header p, .entry-header blockquote { margin: 10px 0 0; color: var(--ink); line-height: 1.65; font-size: 16px; }
.entry-header blockquote { padding: 11px 13px 11px 15px; border-radius: 0 10px 10px 0; border-inline-start: 2px solid var(--top); background: var(--soft); }

.record-section { margin-top: 23px; }
.detail h2, .dialog-heading h2 { font-size: 20px; font-weight: 700; line-height: 1.4; }
.record-form { display: grid; gap: 12px; margin-top: 11px; }
.field { display: grid; gap: 5px; font-size: 14px; font-weight: 650; }
.field textarea { display: block; width: 100%; min-height: 58px; max-height: 240px; resize: none; field-sizing: content; padding: 9px 12px; border: 0; border-radius: 10px; outline-color: var(--accent); background: var(--paper); color: var(--ink); line-height: 1.45; font-size: 16px; font-weight: 400; }
.field textarea::placeholder { color: #657469; opacity: 1; }
.related { margin-block: -4px; }
.related summary { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 44px; color: var(--accent-ink); font-size: 14px; font-weight: 650; cursor: pointer; list-style: none; }
.related summary::-webkit-details-marker { display: none; }
.related summary svg { width: 17px; height: 17px; }
.related[open] summary svg { transform: rotate(180deg); }
.related-count { font-variant-numeric: tabular-nums; margin-left: 3px; }
.related fieldset { min-width: 0; margin: 4px 0 12px; padding: 0; border: 0; }
.related legend { font-size: 13px; font-weight: 650; color: var(--muted); margin-bottom: 5px; }
.related-options { display: flex; flex-wrap: wrap; gap: 3px 14px; }
.related-options label { display: flex; align-items: center; gap: 6px; min-height: 44px; font-size: 14px; cursor: pointer; }
.related-options input { flex: none; width: 17px; height: 17px; margin: 0; accent-color: var(--accent); }
.primary-button, .secondary-button, .danger-button { min-height: 48px; padding: 8px 14px; border: 0; border-radius: 12px; font-size: 16px; font-weight: 650; }
.primary-button { background: var(--accent); color: #fff; }
.secondary-button { background: var(--soft); color: var(--accent-ink); }
.danger-button { background: #8a3c38; color: #fff; }
.form-error { font-size: 14px; color: #8a3c38; }
.completion-button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 44px; margin-top: 10px; padding-inline: 12px; border: 0; border-radius: 10px; background: var(--soft); color: var(--accent-ink); font-size: 14px; font-weight: 650; }
.completion-button[aria-pressed="true"] { background: #d8e5ee; }
.completion-button svg { width: 17px; height: 17px; }

.history { margin-top: 26px; }
.section-heading, .history-top { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.history-count, .empty-state, .history-related, .completion-dates { font-size: 14px; color: var(--muted); }
.empty-state { margin-top: 10px; }
.history-item { position: relative; margin-top: 5px; padding: 0 0 15px 15px; }
.history-item + .history-item { margin-top: 10px; }
.history-item::before { content: ''; position: absolute; top: 19px; left: 0; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }
.history-item time { color: var(--accent-ink); font-size: 13px; font-weight: 650; }
.history-actions { flex: none; }
.history-actions button { padding: 0; min-height: 44px; min-width: 44px; border: 0; border-radius: 8px; background: transparent; color: var(--accent-ink); font-size: 13px; }
.history-item dl { display: grid; gap: 12px; margin: 0; }
.history-item dt { color: var(--muted); font-size: 13px; }
.history-item dd { margin: 2px 0 0; font-size: 16px; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }
.history-related { margin-top: 10px; }
.history-related a { text-underline-offset: 3px; }
.completion-dates summary { cursor: pointer; min-height: 44px; padding-block: 11px; }
.completion-dates ol { margin: 0 0 14px; padding-left: 22px; }

dialog { width: min(calc(100% - 32px), 414px); max-height: calc(100% - 36px); padding: 20px; border: 0; border-radius: 20px; background: var(--ground); color: var(--ink); }
dialog::backdrop { background: #202e2773; }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.dialog-copy { font-size: 15px; margin: 12px 0 18px; line-height: 1.65; }
.dialog-actions, .backup-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.backup-result { margin-top: 12px; font-size: 14px; color: var(--muted); }

#notice { position: fixed; z-index: 2; bottom: max(18px, calc(env(safe-area-inset-bottom) + 6px)); left: 50%; transform: translateX(-50%); width: max-content; max-width: calc(100% - 32px); border-radius: 12px; padding: 10px 15px; background: #24372d; color: #fff; font-size: 14px; pointer-events: none; animation: settle .16s ease-out both; }
#notice:empty { display: none; }
button, .entry-link, .tower-switch a { transition: background-color .14s ease, scale .14s ease; }
button:active, .entry-link:active, .tower-switch a:active { scale: .98; }
@media (hover: hover) {
  .entry-link:hover .entry-title { text-decoration-color: color-mix(in srgb, currentColor 42%, transparent); }
}
.entry-link:active .entry-title, .entry-link:focus-visible .entry-title { text-decoration-color: color-mix(in srgb, currentColor 55%, transparent); }
@media (min-width: 760px) {
  .pyramid { --title-size-bump: 2px; --support-size-bump: 1px; }
}
@keyframes settle { from { opacity: .88; } to { opacity: 1; } }

@media (max-width: 360px) {
  .app-shell { padding-inline: max(15px, env(safe-area-inset-left)) max(15px, env(safe-area-inset-right)); }
  .pyramid { margin-inline: -12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  button:active, .entry-link:active, .tower-switch a:active { scale: none; }
}
