:root {
  color-scheme: light;
  --bg: #f7f4ee;
  --panel: #ffffff;
  --ink: #1f2a26;
  --muted: #6c766f;
  --line: #d8ddd7;
  --brand: #165a4a;
  --accent: #ef6f61;
  --sun: #f0b45a;
  --blue: #4b7fa8;
  --shadow: 0 18px 45px rgba(31, 42, 38, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  width: min(100%, 920px);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 16px calc(92px + env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.kicker {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.86rem;
}

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

h1 {
  margin-bottom: 0;
  font-size: 1.9rem;
}

h2 {
  margin-bottom: 0;
  font-size: 1.15rem;
}

.install-hint {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 11px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--brand);
  font-size: 0.82rem;
  white-space: nowrap;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

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

.metric {
  min-height: 94px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 10px 28px rgba(31, 42, 38, 0.07);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
}

.metric strong {
  display: block;
  margin-top: 10px;
  color: var(--brand);
  font-size: 2rem;
}

.action-row,
.backup-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 14px 0;
}

.primary,
.secondary,
.file-button {
  min-height: 48px;
  border-radius: 8px;
  padding: 12px 14px;
  text-align: center;
  font-weight: 700;
}

.primary {
  background: var(--brand);
  color: #fff;
}

.secondary,
.file-button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
}

.file-button input {
  display: none;
}

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

.section-block,
.form-panel.inline,
.backup-status,
.trend-note {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 14px;
}

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

.entry-list,
.catalog-list {
  display: grid;
  gap: 10px;
}

.entry-item,
.catalog-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfaf7;
}

.entry-item strong,
.catalog-item strong {
  display: block;
  margin-bottom: 4px;
}

.entry-meta,
.catalog-item span {
  color: var(--muted);
  font-size: 0.83rem;
}

canvas {
  display: block;
  width: 100%;
  min-height: 230px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

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

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 650;
}

.form-panel {
  display: grid;
  gap: 12px;
  width: min(100vw - 28px, 560px);
  border: 0;
  border-radius: 8px;
  background: var(--panel);
  padding: 16px;
}

dialog {
  border: 0;
  border-radius: 10px;
  padding: 0;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(22, 90, 74, 0.36);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.icon-button {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #eef2ed;
  color: var(--ink);
  font-size: 1.4rem;
}

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

.duration-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.breakthrough,
.timer-box {
  border-radius: 8px;
  background: #eef6f2;
  color: var(--brand);
  padding: 12px;
}

.timer-box {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 10px;
}

.timer-box strong {
  font-size: 1.4rem;
  font-variant-numeric: tabular-nums;
}

.tabbar {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  width: min(100%, 920px);
  margin: 0 auto;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(247, 244, 238, 0.94);
  backdrop-filter: blur(18px);
}

.tabbar button {
  min-height: 44px;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-weight: 750;
}

.tabbar button.active {
  background: var(--brand);
  color: #fff;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 18px;
  color: var(--muted);
  text-align: center;
}

@media (min-width: 760px) {
  .summary-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .action-row,
  .backup-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 460px) {
  #view-history .section-title {
    align-items: stretch;
    flex-direction: column;
  }
}
