:root {
  color-scheme: light;
  --ink: #1d2528;
  --muted: #617074;
  --line: #d7e0df;
  --paper: #fbfcfa;
  --panel: #ffffff;
  --green: #17845c;
  --red: #b13a31;
  --amber: #b46c1d;
  --blue: #246d92;
  --shadow: 0 16px 40px rgba(24, 40, 44, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Microsoft JhengHei", "Noto Sans TC", system-ui, sans-serif;
  line-height: 1.5;
}

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

button,
.secondary {
  border: 0;
  border-radius: 6px;
  background: var(--ink);
  color: #fff;
  cursor: pointer;
  min-height: 42px;
  padding: 0 16px;
}

button:hover,
.secondary:hover {
  filter: brightness(1.08);
}

.secondary {
  align-items: center;
  background: #eef4f2;
  color: var(--ink);
  display: inline-flex;
}

.file-btn input {
  display: none;
}

.app-header {
  align-items: end;
  background:
    linear-gradient(120deg, rgba(18, 113, 105, 0.92), rgba(33, 66, 78, 0.9)),
    url("assets/hero-workbench.png");
  background-position: center;
  background-size: cover;
  color: #fff;
  display: flex;
  justify-content: space-between;
  min-height: 310px;
  padding: 44px clamp(20px, 5vw, 72px);
}

.kicker {
  font-size: 13px;
  letter-spacing: 0;
  margin: 0 0 8px;
  opacity: 0.82;
  text-transform: uppercase;
}

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

h1 {
  font-size: clamp(38px, 6vw, 72px);
  line-height: 1.05;
  margin-bottom: 14px;
}

h2 {
  font-size: 22px;
  margin-bottom: 10px;
}

.lede {
  font-size: 20px;
  margin-bottom: 0;
  max-width: 760px;
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

main {
  padding: 24px clamp(16px, 4vw, 48px) 56px;
}

.toolbar,
.summary-grid,
.workspace {
  margin-inline: auto;
  max-width: 1360px;
}

.toolbar {
  align-items: end;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(220px, 1.5fr) repeat(5, minmax(140px, 1fr));
}

label span {
  color: var(--muted);
  display: block;
  font-size: 13px;
  margin-bottom: 6px;
}

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

textarea {
  resize: vertical;
}

.summary-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, 1fr);
  margin-top: 18px;
}

.summary-grid article {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.summary-grid span {
  display: block;
  font-size: 32px;
  font-weight: 800;
}

.summary-grid p {
  color: var(--muted);
  margin-bottom: 0;
}

.workspace {
  display: grid;
  gap: 22px;
  grid-template-columns: minmax(0, 1fr) 380px;
  margin-top: 24px;
}

.section-head {
  align-items: baseline;
  display: flex;
  justify-content: space-between;
}

#resultCount {
  color: var(--muted);
}

.cards {
  display: grid;
  gap: 14px;
}

.product-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
}

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

.product-title {
  font-size: 20px;
  font-weight: 800;
  margin: 0 0 4px;
}

.meta {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 12px;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.badge {
  border-radius: 999px;
  display: inline-flex;
  font-size: 13px;
  font-weight: 700;
  padding: 4px 9px;
}

.badge.ok {
  background: #dff4eb;
  color: var(--green);
}

.badge.try {
  background: #fff0d8;
  color: var(--amber);
}

.badge.stop {
  background: #fde4e1;
  color: var(--red);
}

.badge.info {
  background: #e2f0f6;
  color: var(--blue);
}

.product-card dl {
  display: grid;
  gap: 8px 14px;
  grid-template-columns: 92px 1fr;
  margin: 0;
}

.product-card dt {
  color: var(--muted);
}

.product-card dd {
  margin: 0;
}

.steps-title,
.detail-steps-heading {
  font-size: 17px;
  margin: 18px 0 10px;
}

.step-list {
  display: grid;
  gap: 12px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.step-list.compact {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.step-item {
  background: #f7faf8;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.step-media {
  aspect-ratio: 16 / 10;
  background: #eef4f2;
  display: grid;
  place-items: center;
}

.step-media img {
  height: 100%;
  object-fit: cover;
  width: 100%;
}

.step-placeholder {
  color: var(--muted);
  font-weight: 800;
}

.step-copy {
  padding: 12px;
}

.step-number {
  color: var(--blue);
  display: block;
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 4px;
}

.step-copy h4 {
  font-size: 15px;
  margin: 0 0 6px;
}

.step-copy p {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 0;
}

.card-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.card-actions a,
.card-actions button {
  align-items: center;
  background: #eef4f2;
  border-radius: 6px;
  color: var(--ink);
  display: inline-flex;
  min-height: 38px;
  padding: 0 12px;
  text-decoration: none;
}

.side-panel {
  display: grid;
  gap: 16px;
}

.research-panel,
.add-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.research-panel p {
  color: var(--muted);
}

.research-links {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.research-links a {
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  padding: 10px 12px;
  text-decoration: none;
}

#entryForm {
  display: grid;
  gap: 11px;
}

dialog {
  border: 0;
  border-radius: 8px;
  box-shadow: var(--shadow);
  max-width: 900px;
  padding: 24px;
  width: min(94vw, 900px);
}

dialog::backdrop {
  background: rgba(8, 18, 20, 0.55);
}

.icon-close {
  background: #eef4f2;
  color: var(--ink);
  float: right;
  font-size: 24px;
  min-height: 36px;
  padding: 0 12px;
}

.detail-list {
  display: grid;
  gap: 10px 16px;
  grid-template-columns: 110px 1fr;
  margin: 18px 0;
}

.detail-list dt {
  color: var(--muted);
}

.detail-list dd {
  margin: 0;
}

.safety-note {
  background: #fff5df;
  border-left: 4px solid var(--amber);
  border-radius: 6px;
  margin-bottom: 0;
  padding: 12px 14px;
}

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

@media (max-width: 980px) {
  .app-header,
  .workspace {
    display: block;
  }

  .header-actions {
    justify-content: flex-start;
    margin-top: 24px;
  }

  .toolbar {
    grid-template-columns: 1fr 1fr;
  }

  .side-panel {
    margin-top: 22px;
  }
}

@media (max-width: 640px) {
  .app-header {
    min-height: 360px;
  }

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

  .section-head,
  .product-top {
    display: block;
  }

  .product-card dl {
    grid-template-columns: 1fr;
  }

  .step-list.compact {
    grid-template-columns: 1fr;
  }
}
