[hidden] { display: none !important; }

:root {
  --ink: #111111;
  --muted: #6B6B67;
  --page-bg: #F4F2EE;
  --card-bg: #FBFAF7;
  --border: rgba(17, 17, 17, .12);
  --error: #9A3B2E;
  --radius-card: 22px;
  --radius-input: 13px;
  --radius-pill: 999px;
  --shadow-card: 0 8px 20px rgba(40, 34, 28, .06);
  --shadow-preview: 0 6px 16px rgba(40, 34, 28, .12);
  --font-serif: "Noto Serif TC", "Hiragino Mincho ProN", "Songti TC", Georgia, serif;
  --font-display: "Marcellus", "Hiragino Mincho ProN", "Songti TC", Georgia, serif;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--page-bg);
  color: var(--ink);
  font-family: var(--font-serif);
  line-height: 1.6;
}

h1, h2 {
  font-family: var(--font-display);
  font-weight: 400;
  margin: 0 0 .3em;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: 1rem;
  color: inherit;
}

a { color: inherit; }

.page-wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 32px 20px 64px;
}

.page-header {
  margin-bottom: 32px;
}

.page-header h1 {
  font-size: 1.7rem;
}

.page-sub {
  color: var(--muted);
  margin: 0;
}

/* ---- layout ---- */

.layout {
  display: block;
}

@media (min-width: 720px) {
  .layout {
    display: grid;
    grid-template-columns: minmax(320px, 420px) 1fr;
    gap: 32px;
    align-items: start;
  }
}

.panel {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 28px;
}

.panel-form { margin-bottom: 24px; }

@media (min-width: 720px) {
  .panel-form { margin-bottom: 0; }
}

/* ---- form fields ---- */

#label-form { display: flex; flex-direction: column; gap: 22px; }

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

.field > label {
  font-weight: 500;
}

.field-hint {
  margin: 0;
  font-size: .82rem;
  color: var(--muted);
}

.field-error {
  margin: 0;
  font-size: .82rem;
  color: var(--error);
  min-height: 1.1em;
}

input[type="text"],
input[type="date"],
select,
textarea {
  width: 100%;
  padding: 10px 14px;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: var(--radius-input);
  background: #fff;
  transition: box-shadow .18s ease, border-color .18s ease;
}

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

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

/* ---- tag field (風味關鍵字) ---- */

.tag-field {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-input);
  background: #fff;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px 4px 12px;
  background: var(--page-bg);
  border-radius: var(--radius-pill);
  font-size: .9rem;
}

.tag-chip button {
  border: none;
  background: transparent;
  cursor: pointer;
  /* 視覺上是小圓鈕，點擊範圍仍滿足 44px 下限 */
  width: 44px;
  height: 44px;
  min-height: 0;
  margin: -8px -12px -8px -8px;
  border-radius: 50%;
  color: var(--muted);
  transition: background .18s ease, color .18s ease;
}

.tag-chip button:hover { background: var(--border); color: var(--ink); }

#f-flavors-input {
  flex: 1 1 120px;
  min-width: 120px;
  border: none;
  min-height: 44px;
  padding: 4px 2px;
}

#f-flavors-input:focus-visible { outline: none; }

/* ---- dates display ---- */

.dates-display {
  margin: 6px 0 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.dates-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px dashed var(--border);
}

.dates-row dt { color: var(--muted); font-size: .88rem; }

.dates-row dd {
  margin: 0;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

/* ---- buttons ---- */

.btn {
  min-height: 44px;
  padding: 0 22px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--ink);
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease;
}

.btn-primary {
  background: var(--ink);
  color: #fff;
  width: 100%;
}

.btn-secondary {
  background: #fff;
  color: var(--ink);
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-card);
}

.btn:active { transform: translateY(0); }

.btn:disabled {
  opacity: .45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

@media (hover: none) {
  .btn:hover { transform: none; box-shadow: none; }
}

.btn-text {
  align-self: flex-start;
  border: none;
  background: transparent;
  color: var(--muted);
  text-decoration: underline;
  cursor: pointer;
  min-height: 44px;
  padding: 0 4px;
}

@media (prefers-reduced-motion: reduce) {
  .btn, input, select, textarea, .tag-chip button {
    transition-duration: .001s !important;
  }
}

/* ---- preview ---- */

.preview-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

/* 手機上下排，袋面才看得清楚字 */
@media (max-width: 719px) {
  .preview-grid { grid-template-columns: 1fr; }
  .preview-card { max-width: 340px; margin: 0 auto; width: 100%; }
}

.preview-label {
  font-size: 1rem;
  color: var(--muted);
  font-weight: 500;
  margin-bottom: 8px;
}

.preview-frame {
  aspect-ratio: 100 / 125;
  border-radius: 4px;
  box-shadow: var(--shadow-preview);
  background: #fff;
  overflow: hidden;
}

.preview-svg-slot {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: .85rem;
  text-align: center;
  padding: 8px;
}

.preview-svg-slot svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* ---- export panel ---- */

.export-panel {
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

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

.error-summary {
  background: rgba(154, 59, 46, .07);
  border: 1px solid rgba(154, 59, 46, .25);
  border-radius: var(--radius-input);
  padding: 12px 16px;
  color: var(--error);
  font-size: .88rem;
}

.error-summary ul { margin: 0; padding-left: 1.1em; }

.hint {
  margin: 0;
  font-size: .8rem;
  color: var(--muted);
}

/* ---- loading overlay ---- */

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--page-bg);
}

.loading-box {
  max-width: 360px;
  width: 90%;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.loading-title { margin: 0; color: var(--muted); font-size: .92rem; }

.font-progress {
  width: 100%;
  height: 10px;
  appearance: none;
  border: none;
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.font-progress::-webkit-progress-bar { background: var(--border); border-radius: var(--radius-pill); }
.font-progress::-webkit-progress-value { background: var(--ink); border-radius: var(--radius-pill); }
.font-progress::-moz-progress-bar { background: var(--ink); border-radius: var(--radius-pill); }

.loading-status { margin: 0; font-size: .82rem; color: var(--muted); }

.field-note { margin: 4px 0 0; font-size: 13px; color: var(--muted, #6B6B67); }
.field-note:empty { display: none; }
