:root {
  color-scheme: light;
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-soft: #fbfbfd;
  --surface-raised: rgba(255, 255, 255, 0.86);
  --ink: #1d1d1f;
  --muted: #6e6e73;
  --muted-2: #8e8e93;
  --line: rgba(60, 60, 67, 0.16);
  --line-strong: rgba(60, 60, 67, 0.28);
  --blue: #007aff;
  --blue-soft: rgba(0, 122, 255, 0.1);
  --green: #34c759;
  --green-soft: rgba(52, 199, 89, 0.14);
  --orange: #ff9500;
  --orange-soft: rgba(255, 149, 0, 0.14);
  --red: #ff3b30;
  --red-soft: rgba(255, 59, 48, 0.12);
  --tabbar: rgba(250, 250, 252, 0.82);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
  scrollbar-gutter: stable;
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  letter-spacing: 0;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  touch-action: manipulation;
  overscroll-behavior: none;
}

button,
input,
select,
textarea {
  font: inherit;
  touch-action: manipulation;
}

input,
select,
textarea {
  font-size: 16px;
}

button {
  -webkit-tap-highlight-color: transparent;
}

button:focus:not(:focus-visible) {
  outline: none;
}

button:focus-visible {
  outline: 2px solid rgba(0, 122, 255, 0.26);
  outline-offset: 2px;
}

svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.85;
}

.app-shell {
  width: min(100%, 980px);
  min-height: 100svh;
  margin: 0 auto;
  padding: max(10px, env(safe-area-inset-top)) 16px calc(94px + env(safe-area-inset-bottom));
}

.top-bar,
.section-heading,
.panel-heading,
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.top-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  margin: calc(-1 * max(10px, env(safe-area-inset-top))) -16px 4px;
  min-height: calc(48px + env(safe-area-inset-top));
  padding: max(10px, env(safe-area-inset-top)) 16px 6px;
  background: rgba(245, 245, 247, 0.78);
  border-bottom: 1px solid rgba(60, 60, 67, 0.1);
  backdrop-filter: blur(22px) saturate(180%);
}

.top-bar .eyebrow {
  display: none;
}

.top-bar h1 {
  font-size: 1.06rem;
  font-weight: 600;
  line-height: 1.2;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 600;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  color: var(--ink);
  font-size: 2rem;
  font-weight: 600;
  line-height: 1.06;
}

h2 {
  color: var(--ink);
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.08;
}

h3 {
  color: var(--ink);
  font-size: 1.02rem;
  font-weight: 600;
  line-height: 1.25;
}

.section-heading {
  margin: 10px 0 14px;
}

.section-heading .eyebrow {
  color: var(--muted-2);
}

.sync-pill,
.status-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--green-soft);
  color: #1c7c37;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}

.status-wait {
  background: var(--orange-soft);
  color: #9a5a00;
}

.lock-pending .app-shell {
  visibility: hidden;
}

.lock-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: max(18px, env(safe-area-inset-top)) 18px max(18px, env(safe-area-inset-bottom));
  background: var(--bg);
}

.lock-card {
  width: min(100%, 390px);
  display: grid;
  gap: 12px;
  padding: 26px 18px 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-raised);
  text-align: center;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.08);
  backdrop-filter: blur(22px) saturate(180%);
}

.lock-mark {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  justify-self: center;
  border-radius: 50%;
  background: var(--blue-soft);
  color: var(--blue);
}

.lock-mark svg {
  width: 28px;
  height: 28px;
}

.lock-card h2 {
  font-size: 1.55rem;
}

.lock-copy {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.lock-field {
  margin-top: 4px;
  text-align: left;
}

.lock-field input {
  text-align: center;
  font-size: 1.45rem;
  letter-spacing: 0.18em;
}

.lock-biometric-button {
  width: 100%;
}

.lock-error {
  min-height: 1.3em;
  margin-top: 0;
  color: var(--red);
}

.view {
  display: none;
}

.is-hidden {
  display: none !important;
}

.view.is-active {
  display: block;
  animation: viewIn 120ms ease-out both;
}

@keyframes viewIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

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

.metric-card,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: none;
}

.metric-card {
  min-height: 104px;
  padding: 13px;
}

.metric-card span,
.metric-card small {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 500;
}

.metric-card strong {
  display: block;
  margin: 9px 0 6px;
  font-size: clamp(1.16rem, 5.2vw, 1.58rem);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
}

.metric-card-dark {
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink);
  box-shadow: none;
}

.metric-card-dark span,
.metric-card-dark small {
  color: var(--muted);
}

.progress-wrap {
  margin: 12px 0 14px;
}

.progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(60, 60, 67, 0.13);
}

.progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--blue);
  transition: width 200ms ease;
}

.panel {
  margin-top: 12px;
  padding: 14px;
}

.panel-heading {
  margin-bottom: 12px;
}

.panel-heading span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 500;
  white-space: nowrap;
}

.advice-list,
.review-list,
.transaction-list,
.asset-list,
.trend-list,
.simple-list {
  display: grid;
  gap: 0;
}

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

.review-item {
  display: grid;
  gap: 7px;
  min-width: 0;
  min-height: 112px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.review-item.warning {
  border-color: rgba(255, 149, 0, 0.28);
  background: var(--orange-soft);
}

.review-item.danger {
  border-color: rgba(255, 59, 48, 0.24);
  background: var(--red-soft);
}

.review-item span {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 600;
}

.review-item strong {
  color: var(--ink);
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.review-item p {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.advice-item,
.transaction-item,
.asset-item,
.trend-item,
.simple-item {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 54px;
  padding: 12px 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.advice-item + .advice-item,
.transaction-item + .transaction-item,
.asset-item + .asset-item,
.trend-item + .trend-item,
.simple-item + .simple-item {
  border-top: 1px solid var(--line);
}

.advice-item {
  align-items: flex-start;
  padding-left: 24px;
}

.advice-item::before {
  position: absolute;
  top: 18px;
  left: 2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--green);
  content: "";
}

.advice-item.warning::before {
  background: var(--orange);
}

.advice-item.danger::before {
  background: var(--red);
}

.advice-item strong,
.transaction-item strong,
.asset-item strong,
.trend-item strong,
.simple-item strong {
  display: block;
  line-height: 1.25;
  font-weight: 500;
}

.advice-item span,
.transaction-item span,
.asset-item span,
.trend-item span,
.simple-item span {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 400;
  line-height: 1.35;
}

.entry-form,
.asset-form {
  display: grid;
  gap: 12px;
}

.input-shortcuts {
  display: grid;
}

.shortcut-button {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  text-align: left;
}

.shortcut-button span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 500;
}

.shortcut-button strong {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.type-toggle {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  padding: 2px;
  border-radius: 8px;
  background: rgba(118, 118, 128, 0.14);
}

.type-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.type-toggle span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  border-radius: 7px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 500;
}

.type-toggle input:checked + span {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 2px 7px rgba(0, 0, 0, 0.12);
}

.field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.field span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 500;
}

.field input,
.field select,
.compact-input {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  outline: none;
}

.field input,
.field select {
  padding: 0 12px;
}

.field input[type="date"] {
  -webkit-appearance: none;
  appearance: none;
  text-align: left;
}

.field input[type="date"]::-webkit-date-and-time-value {
  min-width: 0;
  text-align: left;
}

.field input:focus,
.field select:focus,
.compact-input:focus-within {
  border-color: rgba(0, 122, 255, 0.58);
  box-shadow: 0 0 0 4px var(--blue-soft);
}

.amount-field input {
  min-height: 78px;
  padding: 0 16px;
  font-size: 2.45rem;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

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

.asset-form {
  grid-template-columns: 1fr;
  gap: 10px;
}

.asset-form .secondary-button {
  width: 100%;
  min-height: 48px;
}

.mini-form {
  display: grid;
  gap: 10px;
}

.quick-categories,
.quick-methods {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}

.quick-categories::-webkit-scrollbar,
.quick-methods::-webkit-scrollbar {
  display: none;
}

.chip {
  flex: 0 0 auto;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  padding: 0 13px;
  font-size: 0.88rem;
  font-weight: 500;
}

.chip.is-active {
  border-color: transparent;
  background: var(--blue-soft);
  color: var(--blue);
}

.method-chip {
  color: var(--muted);
}

.method-chip.is-active {
  border-color: transparent;
  background: var(--green-soft);
  color: #1c7c37;
}

.submit-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(124px, 0.45fr);
  gap: 10px;
}

.primary-button,
.secondary-button,
.danger-button,
.text-button,
.icon-button,
.nav-button {
  border: 0;
  cursor: pointer;
}

.primary-button,
.secondary-button,
.danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-width: 0;
  min-height: 48px;
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 600;
  line-height: 1.15;
  text-align: center;
  white-space: nowrap;
}

.primary-button svg,
.secondary-button svg,
.danger-button svg {
  flex: 0 0 auto;
}

.primary-button {
  width: 100%;
  background: var(--blue);
  color: #fff;
  box-shadow: none;
}

.secondary-button {
  border: 1px solid transparent;
  background: var(--blue-soft);
  color: var(--blue);
}

.danger-button {
  border: 1px solid transparent;
  background: var(--red-soft);
  color: var(--red);
}

.primary-button:disabled,
.secondary-button:disabled,
.danger-button:disabled {
  cursor: default;
  opacity: 0.42;
}

.text-button {
  background: transparent;
  color: var(--blue);
  font-weight: 600;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: transparent;
  color: var(--blue);
  box-shadow: none;
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.edit-button,
.delete-button {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted-2);
}

.edit-button {
  color: var(--blue);
}

.amount-out {
  color: #d70015;
}

.amount-in {
  color: #248a3d;
}

.bar-chart {
  display: grid;
  gap: 10px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(72px, 0.45fr) minmax(90px, 1fr) auto;
  align-items: center;
  gap: 9px;
  font-size: 0.84rem;
  font-weight: 500;
}

.bar-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(60, 60, 67, 0.13);
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--blue);
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 8px;
  background: transparent;
}

.net-worth {
  color: var(--ink);
  font-size: clamp(1.1rem, 5vw, 1.8rem);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.compact-input {
  display: flex;
  align-items: center;
  gap: 4px;
  max-width: 156px;
  padding: 0 10px;
  font-weight: 500;
}

.compact-input input {
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  outline: none;
  font-weight: 500;
}

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

.link-button {
  text-decoration: none;
}

.sync-form {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.security-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.budget-panel {
  display: grid;
  gap: 12px;
}

.budget-panel .secondary-button {
  width: 100%;
}

.sync-buttons {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 12px;
}

.guide-buttons {
  margin-top: 12px;
}

.security-buttons {
  margin-top: 12px;
}

.helper-text,
.settings-row p {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 400;
  line-height: 1.45;
}

.helper-text {
  margin-top: 10px;
}

.setup-list {
  display: grid;
  gap: 8px;
  margin: 14px 0 0;
  padding-left: 1.35rem;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 400;
  line-height: 1.5;
}

.code-details {
  margin-top: 12px;
}

.code-details summary {
  cursor: pointer;
  color: var(--blue);
  font-weight: 500;
}

.code-details pre {
  max-height: 240px;
  overflow: auto;
  margin: 10px 0 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f2f2f7;
  color: var(--ink);
  font-size: 0.74rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.file-button {
  position: relative;
}

.file-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.danger-panel {
  border-color: rgba(255, 59, 48, 0.18);
}

.bottom-nav {
  position: fixed;
  left: 0;
  bottom: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  grid-auto-rows: 56px;
  align-items: center;
  gap: 0;
  width: 100%;
  height: calc(69px + env(safe-area-inset-bottom));
  padding: 6px max(8px, env(safe-area-inset-left)) calc(7px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-right));
  border-top: 1px solid rgba(60, 60, 67, 0.18);
  background: var(--tabbar);
  box-shadow: none;
  backdrop-filter: blur(24px) saturate(180%);
  contain: layout paint;
}

.nav-button {
  display: grid;
  grid-template-rows: 24px 16px;
  place-items: center;
  align-content: center;
  gap: 2px;
  width: 100%;
  height: 56px;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 500;
  line-height: 1;
}

.nav-button svg {
  display: block;
  width: 21px;
  height: 21px;
  margin: 0;
}

.nav-button span {
  display: block;
  height: 16px;
  line-height: 16px;
  white-space: nowrap;
}

.nav-button.is-active {
  background: transparent;
  color: var(--blue);
}

.nav-button:focus-visible {
  outline: none;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(92px + env(safe-area-inset-bottom));
  z-index: 30;
  max-width: calc(100% - 28px);
  transform: translate(-50%, 16px);
  opacity: 0;
  pointer-events: none;
  border-radius: 999px;
  background: rgba(29, 29, 31, 0.92);
  color: #fff;
  padding: 11px 16px;
  font-size: 0.86rem;
  font-weight: 500;
  transition: opacity 160ms ease, transform 160ms ease;
  backdrop-filter: blur(16px) saturate(180%);
}

.toast.is-visible {
  transform: translate(-50%, 0);
  opacity: 1;
}

.empty-state {
  min-height: 48px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 0;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 400;
  text-align: center;
}

@media (hover: hover) {
  .primary-button:hover,
  .icon-button:hover {
    filter: brightness(0.96);
  }

  .secondary-button:hover,
  .chip:hover {
    background-color: rgba(0, 122, 255, 0.08);
  }

  .nav-button:hover {
    background: transparent;
  }

  .edit-button:hover {
    background: var(--blue-soft);
  }

  .delete-button:hover {
    background: var(--red-soft);
    color: var(--red);
  }
}

@media (min-width: 760px) {
  .app-shell {
    padding: 16px 22px 104px;
  }

  .top-bar {
    margin: -16px -22px 8px;
    padding: 16px 22px 8px;
  }

  main {
    max-width: 860px;
    margin: 0 auto;
  }

  .metric-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .metric-card {
    min-height: 126px;
  }

  .metric-card strong {
    font-size: 1.52rem;
  }

  .panel {
    padding: 18px;
  }

  .mini-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .mini-form .secondary-button {
    align-self: end;
  }
}

@media (max-width: 759px) {
  .review-list {
    grid-template-columns: 1fr;
  }

  .metric-grid {
    display: block;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
  }

  .metric-card,
  .metric-card-dark {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
    column-gap: 12px;
    min-height: 64px;
    margin: 0 14px;
    padding: 12px 0;
    border: 0;
    border-radius: 0;
    background: transparent;
  }

  .metric-card + .metric-card {
    border-top: 1px solid var(--line);
  }

  .metric-card span {
    grid-column: 1;
    grid-row: 1;
  }

  .metric-card small {
    grid-column: 1;
    grid-row: 2;
    margin-top: 3px;
  }

  .metric-card strong {
    grid-column: 2;
    grid-row: 1 / 3;
    align-self: center;
    margin: 0;
    font-size: 1.42rem;
    text-align: right;
  }
}

@media (max-width: 390px) {
  .app-shell {
    padding-left: 14px;
    padding-right: 14px;
  }

  .top-bar {
    margin-left: -14px;
    margin-right: -14px;
    padding-left: 14px;
    padding-right: 14px;
  }

  .form-grid,
  .asset-form,
  .security-form,
  .review-list,
  .submit-row,
  .button-row,
  .sync-buttons,
  .guide-buttons {
    grid-template-columns: 1fr;
  }

  .bar-row {
    grid-template-columns: 68px minmax(76px, 1fr) auto;
  }

  .nav-button {
    font-size: 0.62rem;
  }
}
