.design-page {
  min-height: 100vh;
}

.design-topbar,
.design-main {
  width: min(var(--content-max), calc(100% - (var(--page-pad-desktop) * 2)));
  margin-inline: auto;
}

.design-topbar {
  display: flex;
  justify-content: space-between;
  padding-block: 24px;
  border-bottom: 1px solid var(--line);
  color: var(--text-soft);
  font-size: var(--type-label-size);
  font-weight: var(--type-label-weight);
}

.design-topbar a {
  color: var(--text);
  text-decoration: none;
}

.design-main {
  padding-bottom: 80px;
}

.design-intro {
  padding: 80px 0 72px;
}

.design-intro p,
.design-section > header p,
.split-section header p {
  margin: 0 0 8px;
  color: var(--text-soft);
  font-size: var(--type-label-size);
  font-weight: var(--type-label-weight);
}

.design-intro h1 {
  margin: 0;
  font-size: 46px;
  font-weight: 700;
  letter-spacing: -0.05em;
}

.design-intro span {
  display: block;
  margin-top: 14px;
  color: var(--text-soft);
  font-size: var(--type-body-size);
}

.design-section {
  padding: 52px 0;
  border-top: 1px solid var(--line);
}

.design-section > header,
.split-section header {
  margin-bottom: 26px;
}

.design-section h2,
.split-section h2 {
  margin: 0;
  font-size: var(--type-title-size);
  font-weight: var(--type-title-weight);
  letter-spacing: -0.04em;
}

.token-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.color-token {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--surface);
}

.color-token i {
  display: block;
  height: 58px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
  background: var(--swatch);
}

.color-token .focus-swatch {
  outline: 2px solid var(--focus);
  outline-offset: -8px;
  background: var(--surface);
}

.color-token strong,
.color-token code {
  display: block;
}

.color-token strong {
  font-size: var(--type-label-size);
}

.color-token code {
  margin-top: 4px;
  color: var(--text-soft);
  font-family: inherit;
  font-size: var(--type-caption-size);
}

.foundation-list,
.layout-rules {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  margin-top: 24px;
  border-top: 1px solid var(--line);
}

.foundation-list > div,
.layout-rules > div {
  display: flex;
  justify-content: space-between;
  min-height: var(--setting-row-height);
  padding: 18px 4px;
  border-bottom: 1px solid var(--line);
  font-size: var(--type-label-size);
}

.foundation-list > div:nth-child(odd),
.layout-rules > div:nth-child(odd) {
  margin-right: 18px;
}

.foundation-list span,
.layout-rules span {
  color: var(--text-soft);
}

.type-list > div {
  display: grid;
  grid-template-columns: 210px 1fr;
  align-items: baseline;
  min-height: 82px;
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}

.type-list small {
  color: var(--text-soft);
  font-size: var(--type-caption-size);
}

.type-display span { font-size: var(--type-display-size); font-weight: var(--type-display-weight); line-height: var(--type-display-line); }
.type-title span { font-size: var(--type-title-size); font-weight: var(--type-title-weight); line-height: var(--type-title-line); }
.type-heading span { font-size: var(--type-heading-size); font-weight: var(--type-heading-weight); line-height: var(--type-heading-line); }
.type-body span { font-size: var(--type-body-size); font-weight: var(--type-body-weight); line-height: var(--type-body-line); }
.type-label span { font-size: var(--type-label-size); font-weight: var(--type-label-weight); line-height: var(--type-label-line); }
.type-caption span { font-size: var(--type-caption-size); font-weight: var(--type-caption-weight); line-height: var(--type-caption-line); }
.type-amount span { font-size: var(--type-amount-size); font-weight: var(--type-amount-weight); line-height: var(--type-amount-line); }

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

.component-grid article {
  min-width: 0;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-surface);
  background: var(--surface);
}

.component-grid h3 {
  margin: 0 0 18px;
  font-size: var(--type-label-size);
  font-weight: var(--type-label-weight);
}

.component-row,
.design-states {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.wide-example {
  grid-column: 1 / -1;
}

.design-amount {
  margin-top: 18px;
  padding-top: 14px;
}

.design-amount input {
  font-size: 32px;
}

.design-segment {
  margin-bottom: 14px;
}

.design-dock {
  position: static;
  width: min(var(--dock-width), 100%);
  transform: none;
  margin: 0 auto;
}

.design-day {
  width: 110px;
  min-height: 92px;
}

.design-record,
.design-category {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 54px;
}

.design-category-list,
.design-add-category { width: 100%; }

.dialog-rule-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--line);
}

.dialog-rule-grid span {
  min-width: 0;
  padding: 13px 14px;
  background: var(--surface);
  color: var(--text-soft);
  font-size: var(--type-caption-size);
}

.dialog-rule-grid strong {
  display: block;
  margin-bottom: 3px;
  color: var(--text);
  font-size: var(--type-label-size);
}

.design-dialog-content .amount-field {
  padding: 18px 4px 14px;
}

.design-dialog-content .dialog-rule-grid.compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 16px;
}

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

.design-goal-grid .goal-item { min-width: 0; }

.design-date-fields { display: grid; gap: 8px; }

.compact-amount-demo {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.compact-amount-demo span {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-soft);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  font-weight: 630;
  text-align: center;
  white-space: nowrap;
}

.design-period { justify-content: flex-start; }
.design-summary-row { pointer-events: none; }

.design-record > span:nth-child(2) {
  flex: 1;
}

.design-record strong,
.design-record small {
  display: block;
}

.design-record small,
.design-category small {
  color: var(--text-soft);
  font-size: var(--type-caption-size);
}

.design-record b {
  color: var(--expense);
  font-size: 13px;
}

.design-category svg {
  width: 18px;
  height: 18px;
}

.design-category span {
  flex: 1;
  font-size: 13px;
  font-weight: 620;
}

.design-states .empty-state {
  min-height: 42px;
  padding: 0 12px;
}

.loading-demo {
  width: 20px;
  height: 20px;
  border: 2px solid var(--line);
  border-top-color: var(--text);
  border-radius: 50%;
  animation: design-spin 800ms linear infinite;
}

.forced-focus {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.split-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 48px;
}

.split-section > div {
  min-width: 0;
}

.split-section ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.split-section li,
.voice-grid > div {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  font-size: var(--type-body-size);
}

.voice-grid strong,
.voice-grid span {
  display: block;
}

.voice-grid span {
  margin-top: 5px;
  color: var(--text-soft);
  line-height: 1.6;
}

.principle-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.principle-grid span {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--surface);
  font-size: 13px;
  font-weight: 620;
}

.do-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 28px;
}

.do-grid > div {
  padding: 20px;
  border-top: 1px solid var(--line-strong);
}

.do-grid strong,
.do-grid span {
  display: block;
}

.do-grid span {
  margin-top: 12px;
  color: var(--text-soft);
  font-size: 13px;
  line-height: 1.8;
}

@keyframes design-spin { to { transform: rotate(360deg); } }

@media (max-width: 760px) {
  .design-topbar,
  .design-main { width: calc(100% - (var(--page-pad-mobile) * 2)); }
  .design-intro { padding: 56px 4px 50px; }
  .design-intro h1 { font-size: 38px; }
  .design-section { padding: 40px 0; }
  .token-grid { grid-template-columns: repeat(2, 1fr); }
  .foundation-list,
  .layout-rules,
  .component-grid,
  .split-section,
  .principle-grid,
  .do-grid { grid-template-columns: 1fr; }
  .foundation-list > div:nth-child(odd),
  .layout-rules > div:nth-child(odd) { margin-right: 0; }
  .type-list > div { grid-template-columns: 1fr; gap: 10px; }
  .wide-example { grid-column: auto; }
  .compact-amount-demo { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dialog-rule-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .design-goal-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .loading-demo { animation: none; }
}
