:root {
  color-scheme: light;
  --bg: #f7f4ee;
  --surface: #ffffff;
  --surface-soft: #ede7dc;
  --surface-strong: #e2dacd;
  --text: #191813;
  --muted: #6f6a60;
  --border: #e2dacd;
  --brand: #1d2a44;
  --brand-muted: #6b7690;
  --accent: #b8894a;
  --accent-soft: #f1e3cf;
  --hero-text: #fff9ee;
  --danger: #b4453a;
  --danger-soft: #f7e4e0;
  --shadow: 0 12px 36px rgba(25, 24, 19, 0.08);
  --radius: 20px;
}

[data-theme='dark'] {
  color-scheme: dark;
  --bg: #0d1220;
  --surface: #171f31;
  --surface-soft: #222c42;
  --surface-strong: #2a344a;
  --text: #f6f1e7;
  --muted: #a8b0c2;
  --border: #2a344a;
  --brand: #111a2d;
  --brand-muted: #8e9ab4;
  --accent: #d6a563;
  --accent-soft: #2b2418;
  --hero-text: #fff9ee;
  --danger: #ff8a7a;
  --danger-soft: #3a211f;
  --shadow: 0 12px 36px rgba(0, 0, 0, 0.24);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family:
    -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input,
textarea {
  font: inherit;
}

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

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

#app,
.app-shell {
  min-height: 100vh;
}

.page {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: calc(20px + env(safe-area-inset-top)) 16px
    calc(104px + env(safe-area-inset-bottom));
}

.view {
  display: flex;
  flex-direction: column;
  gap: 18px;
  animation: rise 180ms ease-out;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.page-header,
.detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.detail-header {
  align-items: center;
}

.kicker {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.16em;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 4px;
  font-size: clamp(28px, 7vw, 36px);
  line-height: 1.1;
  letter-spacing: -0.04em;
}

h2 {
  margin-bottom: 0;
  font-size: 14px;
  line-height: 1.3;
}

.intro {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.add-button {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--accent);
  color: #151a26;
  font-size: 26px;
  font-weight: 500;
  line-height: 1;
  box-shadow: 0 8px 20px rgba(184, 137, 74, 0.22);
}

.add-button:active,
.primary-button:active,
.secondary-button:active,
.delete-button:active,
.icon-button:active,
.chip:active,
.refresh-button:active {
  transform: scale(0.98);
}

.hero-card {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 162px;
  padding: 22px;
  border-radius: 26px;
  background: var(--brand);
  color: var(--hero-text);
  box-shadow: var(--shadow);
}

.hero-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--brand-muted);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.14em;
}

.hero-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}

.hero-count {
  margin-top: 14px;
  color: var(--accent);
  font-size: 54px;
  font-weight: 600;
  line-height: 0.95;
  letter-spacing: -0.06em;
}

.hero-card p {
  margin-bottom: 0;
  color: var(--brand-muted);
  font-size: 12px;
}

.hero-orbit {
  position: absolute;
  right: 20px;
  bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 112px;
  height: 112px;
  border: 1px solid color-mix(in srgb, var(--accent) 55%, transparent);
  border-radius: 50%;
  color: var(--accent);
  font-size: 30px;
}

.hero-orbit::before,
.hero-orbit::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  border: 1px solid color-mix(in srgb, var(--brand-muted) 40%, transparent);
}

.hero-orbit::before {
  inset: 13px;
}

.hero-orbit::after {
  inset: 27px;
}

.toolbar {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.search-field {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 15px;
  background: var(--surface);
}

.search-field > span:first-child {
  color: var(--muted);
  font-size: 24px;
  line-height: 1;
}

.search-field input {
  min-width: 0;
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 16px;
}

.search-field input::placeholder {
  color: var(--muted);
}

.search-clear {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  padding: 4px;
}

.chip-row {
  display: flex;
  align-items: center;
  gap: 7px;
  overflow-x: auto;
  scrollbar-width: none;
}

.chip-row::-webkit-scrollbar {
  display: none;
}

.chip {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 0 13px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.chip.is-active {
  border-color: var(--accent);
  background: var(--accent);
  color: #151a26;
}

.section-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-top: 4px;
}

.section-row h2 {
  font-size: 15px;
}

.section-row > span {
  color: var(--muted);
  font-size: 12px;
}

.chart-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.chart-card {
  display: flex;
  align-items: stretch;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
}

.chart-card.is-busy {
  opacity: 0.62;
}

.chart-main {
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
  gap: 12px;
  padding: 14px;
}

.chart-symbol {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 13px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 22px;
}

.chart-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 2px;
}

.chart-name-row {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.chart-name-row strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.favorite-mark {
  color: var(--accent);
  font-size: 12px;
}

.chart-meta {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chart-actions {
  display: flex;
  align-items: center;
  gap: 1px;
  padding-right: 7px;
}

.icon-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 44px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 21px;
  line-height: 1;
}

.icon-button.danger {
  color: var(--danger);
}

.icon-button:disabled {
  opacity: 0.45;
}

.chevron {
  padding: 0 8px;
  color: var(--muted);
  font-size: 25px;
  line-height: 1;
}

.section-block {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.section-block h2 {
  margin-top: 2px;
}

.settings-card,
.info-card,
.form-card,
.install-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.settings-card {
  padding: 0 16px;
}

.settings-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 66px;
}

.settings-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 11px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 16px;
}

.settings-copy {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 2px;
  min-width: 0;
}

.settings-copy strong {
  font-size: 13px;
}

.settings-copy small {
  color: var(--muted);
  font-size: 11px;
}

.switch {
  position: relative;
  flex: 0 0 auto;
  width: 50px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 15px;
  background: var(--surface-strong);
  transition: background 160ms ease;
}

.switch span {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
  transition: transform 160ms ease;
}

.switch.is-on {
  background: var(--accent);
}

.switch.is-on span {
  transform: translateX(20px);
}

.install-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
}

.install-card p,
.about-text {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.primary-button,
.secondary-button,
.delete-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 52px;
  border-radius: 16px;
  font-size: 14px;
  font-weight: 750;
}

.primary-button {
  border: 0;
  background: var(--accent);
  color: #151a26;
}

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

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

.delete-button.full-width {
  margin-top: 0;
}

.action-stack {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.detail-header {
  min-height: 36px;
}

.back-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text);
  font-size: 26px;
  line-height: 1;
}

.detail-hero {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 23px;
  border-radius: 24px;
  background: var(--brand);
  color: var(--hero-text);
  box-shadow: var(--shadow);
}

.detail-symbol {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 27px;
}

.detail-hero h1 {
  margin: 8px 0 0;
  font-size: 29px;
}

.detail-hero p {
  margin: 0;
  color: var(--brand-muted);
  font-size: 12px;
}

.info-card {
  padding: 0 16px;
}

.info-card dl {
  margin: 0;
}

.info-row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.info-row:last-child {
  border-bottom: 0;
}

.info-row dt {
  flex: 0 0 112px;
  color: var(--muted);
  font-size: 12px;
}

.info-row dd {
  flex: 1;
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.form-card {
  display: flex;
  flex-direction: column;
  gap: 15px;
  padding: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field > span:first-child {
  color: var(--muted);
  font-size: 11px;
}

.field input,
.field textarea {
  width: 100%;
  min-height: 48px;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 13px;
  outline: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
}

.field textarea {
  resize: vertical;
  line-height: 1.45;
}

.field input:focus,
.field textarea:focus,
.search-field:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

.field.has-error input,
.field.has-error textarea {
  border-color: var(--danger);
}

.field-error {
  color: var(--danger);
  font-size: 11px;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  font-size: 12px;
  line-height: 1.4;
}

.notice-error {
  border-color: var(--danger);
  background: var(--danger-soft);
  color: var(--danger);
}

.text-button {
  flex: 0 0 auto;
  border: 0;
  background: transparent;
  color: inherit;
  font-size: 12px;
  font-weight: 750;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 54px 24px;
  text-align: center;
}

.empty-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 76px;
  height: 76px;
  margin-bottom: 6px;
  border: 1px solid var(--accent);
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 32px;
}

.empty-state h2 {
  font-size: 17px;
}

.empty-state p {
  max-width: 280px;
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.empty-state .primary-button {
  width: auto;
  min-width: 160px;
  padding: 0 20px;
}

.skeleton-card {
  height: 76px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-soft) 37%, var(--surface) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
}

@keyframes shimmer {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: -100% 0;
  }
}

.refresh-button {
  align-self: center;
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}

.detail-loading {
  padding: 70px 20px;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
}

.about-name {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 16px 0 10px;
}

.about-name strong {
  font-size: 17px;
}

.about-text {
  padding-bottom: 14px;
}

.version-badge {
  padding: 5px 7px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9px;
  font-weight: 700;
}

.about-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 11px;
}

.about-meta strong {
  color: var(--text);
  font-weight: 600;
}

.footer-note {
  margin: 2px 0 0;
  color: var(--muted);
  text-align: center;
  font-size: 11px;
}

.bottom-nav {
  position: fixed;
  z-index: 20;
  right: 0;
  bottom: 0;
  left: 0;
  padding: 8px 16px calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid color-mix(in srgb, var(--border) 75%, transparent);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-around;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
}

.nav-item {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-height: 45px;
  padding: 5px 4px;
  border-radius: 12px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
}

.nav-item.is-active {
  color: var(--accent);
}

.nav-icon {
  font-size: 19px;
  line-height: 22px;
}

.nav-label {
  line-height: 1.2;
}

.toast {
  position: fixed;
  z-index: 30;
  right: 16px;
  bottom: calc(82px + env(safe-area-inset-bottom));
  left: 16px;
  max-width: 480px;
  margin: 0 auto;
  padding: 11px 14px;
  border: 1px solid var(--accent);
  border-radius: 13px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 650;
  text-align: center;
  box-shadow: var(--shadow);
}

.toast-error {
  border-color: var(--danger);
  background: var(--danger-soft);
  color: var(--danger);
}

.boot {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  gap: 7px;
  background: var(--brand);
  color: var(--hero-text);
}

.boot-mark {
  color: var(--accent);
  font-size: 46px;
}

.boot-name {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.boot-text {
  color: var(--brand-muted);
  font-size: 12px;
}

.noscript {
  padding: 24px;
  color: var(--danger);
  text-align: center;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (min-width: 640px) {
  .page {
    padding-right: 24px;
    padding-left: 24px;
  }

  .chart-list {
    gap: 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
