:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --ink: #17202a;
  --muted: #687386;
  --line: #dce2ea;
  --accent: #1267d8;
  --accent-dark: #0b4ea8;
  --stable: #18864b;
  --warn: #b56a00;
  --risk: #b3261e;
  --shadow: 0 8px 24px rgba(23, 32, 42, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Yu Gothic", sans-serif;
  line-height: 1.5;
}

button,
input,
select,
textarea {
  font: inherit;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  width: 100%;
  max-width: 100vw;
  background: rgba(245, 247, 251, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.app-header > div {
  min-width: 0;
}

h1,
h2,
h3,
p {
  margin: 0;
  overflow-wrap: anywhere;
}

h1 {
  font-size: 21px;
  line-height: 1.2;
}

h2 {
  font-size: 20px;
  line-height: 1.25;
}

h3 {
  font-size: 16px;
}

main {
  width: min(960px, 100%);
  max-width: 100vw;
  margin: 0 auto;
  padding: 16px;
}

.eyebrow,
.label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.hero-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.hero-panel p:last-child {
  margin-top: 6px;
  color: var(--muted);
}

.score-ring {
  display: grid;
  flex: 0 0 92px;
  width: 92px;
  height: 92px;
  place-items: center;
  border: 8px solid #dcecff;
  border-radius: 50%;
  background: #ffffff;
}

.score-ring span {
  font-size: 28px;
  font-weight: 800;
  line-height: 1;
}

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

.tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 14px 0;
}

.tab,
.primary-button,
.ghost-button,
.small-button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
}

.tab {
  padding: 10px 8px;
  background: #e8edf5;
  color: var(--muted);
}

.tab.active {
  background: var(--accent);
  color: #fff;
}

.primary-button {
  padding: 10px 14px;
  background: var(--accent);
  color: #fff;
}

.primary-button:hover {
  background: var(--accent-dark);
}

.ghost-button,
.small-button {
  padding: 9px 12px;
  background: #fff;
  border-color: var(--line);
  color: var(--ink);
}

.small-button {
  min-height: 34px;
  padding: 6px 10px;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 18px 0 12px;
}

.input-card,
.trick-card,
.notice,
.routine-summary {
  margin: 12px 0;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.input-card {
  display: grid;
  gap: 12px;
}

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

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 10px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

textarea {
  min-height: 180px;
  resize: vertical;
}

.list {
  display: grid;
  gap: 10px;
  margin: 12px 0 24px;
}

.trick-card {
  display: grid;
  gap: 10px;
}

.card-main {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.card-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.card-title strong {
  font-size: 17px;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #edf2f8;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.pill.stable {
  background: #e3f5eb;
  color: var(--stable);
}

.pill.warn {
  background: #fff1d8;
  color: var(--warn);
}

.pill.risk {
  background: #fde8e6;
  color: var(--risk);
}

.progress {
  overflow: hidden;
  height: 8px;
  background: #e8edf5;
  border-radius: 999px;
}

.progress span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: inherit;
}

.progress span.stable {
  background: var(--stable);
}

.progress span.warn {
  background: var(--warn);
}

.progress span.risk {
  background: var(--risk);
}

.routine-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.routine-summary strong {
  display: block;
  margin-top: 2px;
  font-size: 19px;
}

.notice {
  color: var(--muted);
}

.manual-card p,
.manual-steps p,
.notice {
  font-size: 15px;
}

.manual-steps {
  display: grid;
  gap: 10px;
  margin: 12px 0;
}

.manual-table {
  display: grid;
  gap: 10px;
}

.manual-table div {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.manual-table div:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.manual-table strong {
  font-size: 14px;
}

.manual-table span {
  color: var(--muted);
  font-size: 14px;
}

dialog {
  width: min(680px, calc(100% - 24px));
  border: 1px solid var(--line);
  border-radius: 8px;
}

dialog::backdrop {
  background: rgba(23, 32, 42, 0.4);
}

dialog form {
  display: grid;
  gap: 12px;
}

.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

@media (max-width: 640px) {
  .app-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: flex-start;
    gap: 10px;
  }

  .ghost-button {
    justify-self: end;
    white-space: nowrap;
    min-height: 36px;
    padding: 7px 10px;
  }

  main {
    padding: 12px;
  }

  .hero-panel,
  .section-head,
  .card-main {
    align-items: stretch;
    flex-direction: column;
  }

  .score-ring {
    align-self: flex-start;
  }

  .form-grid,
  .routine-summary {
    grid-template-columns: 1fr;
  }

  .tabs {
    position: sticky;
    top: 73px;
    z-index: 9;
    grid-template-columns: repeat(2, 1fr);
    margin-inline: 0;
    padding: 8px 0;
    background: rgba(245, 247, 251, 0.95);
    border-bottom: 1px solid var(--line);
  }

  .tab {
    min-height: 40px;
    font-size: 12px;
  }

  .dialog-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .manual-table div {
    grid-template-columns: 1fr;
    gap: 4px;
  }
}
