:root {
  color-scheme: light;
  --paper: #f4f1e9;
  --ink: #171715;
  --muted: #77736b;
  --line: #d8d2c7;
  --future: #ddd7cc;
  --accent: #e9573f;
  --accent-soft: #f6d9d2;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); }
button, input, select, textarea { font: inherit; }
button { color: inherit; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.app-shell { width: min(100%, 680px); margin: 0 auto; min-height: 100vh; padding: 0 24px 40px; }
.app-header { display: flex; align-items: center; justify-content: space-between; min-height: 86px; border-bottom: 1px solid var(--line); }
.app-title { margin: 0; font-size: clamp(2.2rem, 8vw, 3.4rem); line-height: .95; font-weight: 600; letter-spacing: -.06em; }
.header-actions { display: flex; gap: 14px; align-items: center; }
.header-link, .text-button { background: none; border: 0; padding: 0; color: var(--muted); cursor: pointer; text-decoration: none; }
.header-link:hover, .text-button:hover { color: var(--ink); }
.add-goal { width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 50%; background: transparent; font-size: 1.6rem; line-height: 1; cursor: pointer; }
.add-goal:hover { border-color: var(--ink); }

.goal-list { margin: 0; padding: 0; list-style: none; }
.goal-card { position: relative; border-bottom: 1px solid var(--line); }
.goal-open { display: block; width: 100%; padding: 31px 44px 32px 0; background: none; border: 0; text-align: left; cursor: pointer; }
.goal-summary, .goal-progress-column { display: block; min-width: 0; }
.goal-top { display: flex; justify-content: space-between; align-items: center; gap: 18px; }
.goal-title { margin: 0; font-size: 1.42rem; font-weight: 500; letter-spacing: -.04em; }
.goal-edit-button { position: absolute; z-index: 2; top: 25px; right: -8px; display: grid; width: 42px; height: 42px; padding: 0; place-items: center; border: 0; border-radius: 7px; background: transparent; color: var(--muted); cursor: pointer; }
.edit-icon { display: grid; width: 34px; height: 34px; flex: 0 0 auto; place-items: center; border-radius: 6px; color: var(--muted); }
.edit-icon svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.goal-edit-button:hover, .goal-edit-button:focus-visible { background: rgba(23,23,21,.06); color: var(--ink); }
.goal-edit-button:hover .edit-icon, .goal-edit-button:focus-visible .edit-icon { color: var(--ink); }
.goal-value { display: block; margin: 23px 0 13px; font-size: clamp(2.35rem, 11.2vw, 5.15rem); line-height: .94; font-weight: 400; letter-spacing: -.07em; overflow-wrap: anywhere; }
.goal-meta { display: block; color: var(--muted); font-size: 1.05rem; line-height: 1.35; }
.overall-progress { display: grid; gap: 9px; margin-top: 23px; }
.overall-progress-copy { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; color: var(--muted); font-size: .88rem; line-height: 1.25; }
.overall-progress-copy span:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.overall-progress-copy strong { color: var(--ink); font-size: 1.05rem; font-weight: 560; letter-spacing: -.02em; }
.overall-progress-track { display: block; height: 5px; overflow: hidden; border-radius: 2px; background: var(--line); }
.overall-progress-track > span { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width .25s ease; }
.tiles { display: flex; gap: clamp(7px, 2.4vw, 14px); margin-top: 27px; align-items: start; }
.tile-wrap { display: grid; grid-template-rows: 48px auto auto; gap: 7px; min-width: 0; flex: 1; text-align: center; }
.tile { --segment-color: var(--ink); --segment-empty: rgba(244,241,233,.82); position: relative; display: grid; min-height: 48px; place-items: center; overflow: hidden; border-radius: 7px; background: var(--future); }
.tile-fill { position: absolute; inset: 0 auto 0 0; min-width: 0; background: var(--ink); }
.tile.current .tile-fill { background: var(--accent); }
.tile.future .tile-fill { background: #a7a196; }
.tile.current { --segment-color: var(--accent); }
.tile.future { --segment-color: #a7a196; }
.tile-mark { position: relative; z-index: 1; color: var(--paper); font-size: 1.38rem; font-weight: 500; }
.segment-grid { position: absolute; inset: 5px; display: grid; grid-template-columns: repeat(var(--segment-columns), minmax(0, 1fr)); grid-template-rows: repeat(var(--segment-rows), minmax(0, 1fr)); gap: 2px; }
.segment-grid.compact { inset: 4px; gap: 1.25px; }
.segment-grid.dense { inset: 4px; gap: 1px; }
.segment-cell { min-width: 0; min-height: 0; border-radius: 1px; background: var(--segment-empty); }
.segment-cell.is-filled { background: var(--segment-color); }
.segment-cell.is-partial { background: linear-gradient(90deg, var(--segment-color) var(--segment-progress), var(--segment-empty) var(--segment-progress)); }
.tile-label { color: var(--muted); font-size: .88rem; line-height: 1.15; overflow-wrap: anywhere; }
.tile-count { color: var(--ink); font-size: .78rem; line-height: 1.15; font-variant-numeric: tabular-nums; }
.empty { padding: 64px 0; color: var(--muted); text-align: center; }

.panel { padding: 20px 0 40px; }
.back { display: inline-flex; align-items: center; gap: 6px; padding: 0; border: 0; background: none; color: var(--muted); cursor: pointer; }
.view-nav { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.edit-structure { display: inline-flex; align-items: center; gap: 7px; padding: 7px 0; border: 0; background: none; color: var(--muted); cursor: pointer; }
.edit-structure:hover { color: var(--ink); }
.edit-structure svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.detail-head { padding: 38px 0 30px; border-bottom: 1px solid var(--line); }
.detail-summary, .detail-progress { min-width: 0; }
.detail-head .goal-value { margin-top: 21px; }
.detail-section { padding: 27px 0; border-bottom: 1px solid var(--line); }
.detail-section h2 { margin: 0 0 18px; font-size: 1.22rem; font-weight: 500; letter-spacing: -.03em; }
.section-title-row { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.section-title-row h2 { margin: 0; }
.autosave-status { min-height: 1em; color: var(--muted); font-size: .78rem; text-align: right; }
.autosave-status.is-error { color: #9b2a20; }
.milestone-list, .event-list { margin: 0; padding: 0; list-style: none; }
.event-row { display: flex; justify-content: space-between; gap: 12px; padding: 14px 0; border-top: 1px solid color-mix(in srgb, var(--line), transparent 30%); }
.event-row:first-child { border-top: 0; }
.event-kind { display: block; margin-bottom: 4px; color: var(--muted); font-size: .72rem; letter-spacing: .04em; text-transform: uppercase; }
.section-hint { color: var(--muted); font-size: .78rem; text-align: right; }
.section-note { margin: -8px 0 20px; max-width: 520px; color: var(--muted); font-size: .92rem; line-height: 1.4; }
.work-list { display: grid; grid-template-columns: 1fr; gap: 12px; margin: 0; padding: 0; list-style: none; }
.work-milestone { display: grid; gap: 13px; padding: 18px; border: 1px solid var(--line); border-radius: 8px; }
.work-milestone-main { display: flex; align-items: start; justify-content: space-between; gap: 16px; }
.work-milestone-copy { display: grid; gap: 5px; }
.work-milestone-title { font-size: 1.05rem; font-weight: 520; letter-spacing: -.02em; }
.work-milestone-value, .work-percentage { color: var(--muted); font-size: .84rem; font-variant-numeric: tabular-nums; }
.work-track { display: block; height: 4px; overflow: hidden; border-radius: 2px; background: var(--line); }
.work-track > span { display: block; height: 100%; background: var(--accent); }
.work-button { justify-self: start; min-height: 38px; padding-inline: 13px; font-size: .88rem; }
.work-button:disabled { color: var(--muted); cursor: default; opacity: .75; }
.editor-head { padding: 42px 0 35px; border-bottom: 1px solid var(--line); }
.editor-kicker { display: block; margin-bottom: 8px; color: var(--accent); font-size: .78rem; font-weight: 600; letter-spacing: .055em; text-transform: uppercase; }
.editor-head h1 { margin: 0; font-size: clamp(2rem, 8vw, 4rem); line-height: 1; font-weight: 500; letter-spacing: -.055em; }
.editor-head p { max-width: 610px; margin: 16px 0 0; color: var(--muted); line-height: 1.45; }
.milestone-card { position: relative; padding: 17px 76px 17px 0; border-top: 1px solid color-mix(in srgb, var(--line), transparent 20%); transition: opacity .15s ease, transform .15s ease; }
.milestone-card:first-child { border-top: 0; padding-top: 0; }
.milestone-card.is-dragging { opacity: .52; transform: scale(.99); pointer-events: none; }
.milestone-form { display: grid; gap: 12px; }
.milestone-form label, .milestone-fields label { display: grid; gap: 6px; color: var(--muted); font-size: .78rem; }
.milestone-form input, .milestone-form select, .milestone-fields input, .milestone-fields select { width: 100%; min-width: 0; min-height: 42px; border: 1px solid var(--line); border-radius: 6px; background: rgba(255,255,255,.22); color: var(--ink); padding: 0 10px; outline-color: var(--accent); }
.milestone-title-field input { border-color: transparent; border-bottom-color: var(--line); border-radius: 0; background: transparent; padding-inline: 0; font-size: 1.08rem; font-weight: 500; }
.milestone-fields { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; }
.milestone-structure-fields { grid-template-columns: minmax(100px, .55fr) minmax(130px, .8fr) minmax(180px, 1.4fr); align-items: end; }
.milestone-current-note { align-self: center; padding-bottom: 12px; color: var(--muted); font-size: .82rem; font-variant-numeric: tabular-nums; }
.milestone-tools { position: absolute; top: 17px; right: 0; display: flex; gap: 4px; }
.milestone-card:first-child .milestone-tools { top: 0; }
.icon-button { display: grid; width: 32px; height: 32px; padding: 0; place-items: center; border: 0; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; }
.icon-button:hover, .icon-button:focus-visible { background: rgba(23,23,21,.06); color: var(--ink); }
.drag-handle { touch-action: none; cursor: grab; font-size: 1.3rem; line-height: 1; }
.drag-handle:active { cursor: grabbing; }
.delete-milestone { color: #a34a3e; }
.delete-milestone svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.event-title { font-weight: 500; }
.event-detail, .event-date { display: block; color: var(--muted); font-size: .94rem; margin-top: 3px; }
.button { min-height: 44px; padding: 0 16px; border-radius: 7px; border: 1px solid var(--line); background: transparent; cursor: pointer; }
.button-primary { border-color: var(--ink); background: var(--ink); color: var(--paper); }
.button-primary:hover { background: #30302c; }
.button-danger { border-color: #b53d2e; color: #9b2a20; }
.button-quiet { border: 0; color: var(--muted); }
.form { display: grid; gap: 16px; }
.form label { display: grid; gap: 7px; color: var(--muted); font-size: .95rem; }
.form input, .form select, .form textarea { width: 100%; min-height: 45px; border: 1px solid var(--line); border-radius: 7px; background: rgba(255,255,255,.25); color: var(--ink); padding: 0 12px; outline-color: var(--accent); }
.form textarea { min-height: 88px; padding-block: 11px; resize: vertical; line-height: 1.4; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; padding-top: 4px; }
.add-milestone, .add-event { margin-top: 20px; }
.note-form { max-width: 620px; }
.note-form .button { justify-self: start; }
.add-milestone { padding: 20px; border: 1px solid var(--line); border-radius: 8px; }
.add-milestone h3 { margin: 0; font-size: 1.02rem; font-weight: 500; }
.settings-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.dialog { width: min(calc(100% - 32px), 520px); border: 0; border-radius: 10px; padding: 24px; background: var(--paper); color: var(--ink); box-shadow: 0 20px 80px rgba(0,0,0,.24); }
.dialog::backdrop { background: rgba(20,19,17,.36); }
.dialog-title { margin: 0 0 22px; font-size: 1.55rem; letter-spacing: -.04em; }
.dialog-note { margin: -12px 0 22px; color: var(--muted); }
.notice { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); max-width: calc(100% - 40px); padding: 12px 16px; border-radius: 10px; background: var(--ink); color: var(--paper); opacity: 0; pointer-events: none; transition: opacity .2s ease; }
.notice.is-visible { opacity: 1; }

.account-email { max-width: 210px; overflow: hidden; color: var(--muted); font-size: .82rem; text-overflow: ellipsis; white-space: nowrap; }
.auth-shell { width: min(100%, 1120px); min-height: 100vh; margin: 0 auto; padding: 42px 24px; display: grid; align-items: center; gap: 54px; }
.auth-intro { max-width: 600px; }
.auth-wordmark { display: block; margin-bottom: 56px; font-size: 1.12rem; font-weight: 600; letter-spacing: -.03em; }
.auth-intro h1 { margin: 0; font-size: clamp(3.25rem, 8vw, 6.8rem); line-height: .88; font-weight: 500; letter-spacing: -.075em; }
.auth-intro p { max-width: 490px; margin: 28px 0 0; color: var(--muted); font-size: 1.12rem; line-height: 1.45; }
.auth-panel { width: 100%; max-width: 430px; justify-self: end; padding: 30px; border: 1px solid var(--line); border-radius: 10px; }
.auth-tabs { display: flex; gap: 22px; margin-bottom: 42px; border-bottom: 1px solid var(--line); }
.auth-tab { position: relative; padding: 0 0 12px; border: 0; background: none; color: var(--muted); cursor: pointer; }
.auth-tab.is-active { color: var(--ink); }
.auth-tab.is-active::after { content: ''; position: absolute; right: 0; bottom: -1px; left: 0; height: 2px; background: var(--accent); }
.auth-panel h2 { margin: 0; font-size: 1.85rem; font-weight: 500; letter-spacing: -.045em; }
.auth-note { min-height: 3em; margin: 10px 0 24px; color: var(--muted); font-size: .92rem; line-height: 1.4; }
.auth-form .button { margin-top: 4px; }
.auth-form .button:disabled { opacity: .55; cursor: wait; }
.auth-error { min-height: 1.3em; color: #9b2a20; font-size: .85rem; }

@media (min-width: 640px) {
  .app-shell { padding-inline: 38px; }
  .goal-open { padding-block: 34px; }
  .work-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 900px) {
  .app-shell { width: min(100%, 1180px); padding: 0 48px 64px; }
  .app-header { min-height: 108px; }
  .app-title { font-size: 3.35rem; }
  .goal-open { display: grid; grid-template-columns: minmax(280px, .84fr) minmax(430px, 1.16fr); gap: clamp(48px, 6vw, 86px); align-items: center; min-height: 248px; padding: 42px 42px 43px 0; }
  .goal-open .goal-top { display: block; }
  .goal-edit-button { top: 34px; right: -9px; }
  .goal-open .goal-value { margin: 24px 0 12px; font-size: clamp(3.1rem, 4.2vw, 4.35rem); }
  .goal-progress-column .overall-progress { margin-top: 0; }
  .goal-progress-column .tiles { margin-top: 32px; }
  .goal-progress-column .tile-wrap { grid-template-rows: 54px auto auto; }
  .goal-progress-column .tile { min-height: 54px; }
  .panel { padding-top: 30px; }
  .detail-head { display: grid; grid-template-columns: minmax(280px, .84fr) minmax(430px, 1.16fr); gap: clamp(48px, 6vw, 86px); align-items: center; min-height: 280px; padding: 45px 0 46px; }
  .detail-head .goal-value { margin: 24px 0 13px; font-size: clamp(3.1rem, 4.2vw, 4.35rem); }
  .detail-progress .overall-progress { margin-top: 0; }
  .detail-progress .tiles { margin-top: 32px; }
  .detail-section { padding: 34px 0; }
  .detail-section h2 { font-size: 1.35rem; }
  .work-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .milestone-card { padding-block: 21px; }
  .milestone-card:first-child { padding-top: 0; }
  .milestone-tools { top: 21px; }
  .milestone-card:first-child .milestone-tools { top: 0; }
  .auth-shell { grid-template-columns: minmax(0, 1.25fr) minmax(360px, .75fr); padding: 60px 48px; }
}

@media (max-width: 520px) {
  .account-email { display: none; }
  .header-actions { gap: 11px; }
  .auth-shell { align-content: start; padding-top: 28px; gap: 44px; }
  .auth-wordmark { margin-bottom: 40px; }
  .auth-intro h1 { font-size: 3.65rem; }
  .auth-intro p { margin-top: 22px; font-size: 1rem; }
  .auth-panel { padding: 22px; }
  .milestone-card { padding-right: 68px; }
  .milestone-fields { grid-template-columns: 1fr 1fr; }
  .milestone-structure-fields { grid-template-columns: 1fr 1fr; }
  .milestone-current-note { grid-column: 1 / -1; padding-bottom: 0; }
  .tile-label { font-size: .78rem; }
  .tile-count { font-size: .72rem; }
}
