:root {
  --bg: #ffffff;
  --soft: #f7f8fb;
  --line: #e3e7ee;
  --text: #111827;
  --muted: #64748b;
  --blue: #2f6fed;
  --blue-soft: #edf4ff;
  --danger: #c2410c;
  --radius: 12px;
  --font: "IBM Plex Sans", "Noto Sans JP", "BIZ UDPGothic", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--soft);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.7;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  letter-spacing: 0;
}

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

button {
  cursor: pointer;
}

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

.app-header {
  padding: 34px 18px 26px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}

.app-header > div,
.app-shell {
  width: min(100% - 32px, 920px);
  margin: 0 auto;
}

.eyebrow {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

h1 {
  margin-bottom: 8px;
  font-size: clamp(2rem, 7vw, 3.1rem);
  line-height: 1.12;
}

.lead,
.quiet {
  color: var(--muted);
}

.app-shell {
  padding: 18px 0 72px;
}

.tabs {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  gap: 8px;
  padding: 10px 0 14px;
  overflow-x: auto;
  background: var(--soft);
}

.tab {
  min-height: 38px;
  padding: 8px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg);
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
  white-space: nowrap;
}

.tab.is-active {
  border-color: #c8dcff;
  background: var(--blue-soft);
  color: var(--blue);
}

.view {
  display: none;
  padding: 22px 0 0;
}

.view.is-active {
  display: block;
}

.flow {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 18px;
}

.flow span {
  min-height: 38px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-align: center;
}

h2 {
  margin-bottom: 18px;
  font-size: 1.25rem;
  line-height: 1.35;
}

h3 {
  margin-bottom: 12px;
  font-size: 1rem;
  line-height: 1.45;
}

label {
  display: block;
  min-width: 0;
  margin-bottom: 14px;
}

label span {
  display: block;
  margin-bottom: 7px;
  font-size: 0.84rem;
  font-weight: 700;
}

input,
select,
textarea {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  outline: 3px solid rgba(47, 111, 237, 0.13);
}

.grid {
  display: grid;
  gap: 12px;
}

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

.grid.three {
  grid-template-columns: 0.7fr 1fr 0.72fr;
}

.section-box,
.notice {
  margin-bottom: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
}

.notice {
  color: var(--muted);
  font-size: 0.88rem;
}

.notice p + p {
  margin-top: 12px;
}

.section-title {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(180px, 1fr);
  gap: 12px;
  align-items: start;
}

.button-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.button,
.file-button {
  display: inline-flex;
  min-height: 44px;
  padding: 10px 16px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font-weight: 700;
  line-height: 1.2;
}

.button.primary {
  width: 100%;
  min-height: 52px;
  border-color: var(--blue);
  background: var(--blue);
  color: #ffffff;
}

.button.secondary:hover,
.file-button:hover {
  border-color: var(--blue);
  color: var(--blue);
}

.file-button input {
  display: none;
}

.line-list,
.saved-list {
  display: grid;
  gap: 8px;
}

.line-card,
.saved-card {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfcff;
}

.line-card header,
.saved-card header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.line-card strong,
.saved-card strong {
  font-size: 0.94rem;
}

.line-card small,
.saved-card small {
  color: var(--muted);
}

.remove-button {
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.totals {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.totals div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.totals div:last-child {
  font-size: 1.1rem;
}

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

.status {
  min-height: 1.7em;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.status.is-error {
  color: var(--danger);
}

@media (max-width: 640px) {
  .app-header > div,
  .app-shell {
    width: min(100% - 28px, 920px);
  }

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

  .tabs {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    overflow-x: visible;
  }

  .tab {
    min-width: 0;
    min-height: 36px;
    padding: 7px 4px;
    overflow: hidden;
    font-size: 0.72rem;
    text-overflow: clip;
  }

  .grid.two,
  .grid.three,
  .section-title,
  .list-grid {
    grid-template-columns: 1fr;
  }

  .section-box,
  .notice {
    padding: 14px;
  }

  .button-row .button,
  .file-button {
    flex: 1 1 150px;
  }
}
