:root {
  --bg: #f6f2ea;
  --card: #ffffff;
  --text: #1f1f1f;
  --muted: #6b6b6b;
  --accent: #1a6b5b;
  --border: #e2dccf;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Noto Serif TC", "PingFang TC", "Microsoft JhengHei", serif;
  background: var(--bg);
  color: var(--text);
}

.container {
  max-width: 720px;
  padding: 24px;
  margin: 0 auto;
}

h1 {
  margin-bottom: 8px;
}

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

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  display: grid;
  gap: 12px;
}

.container > .card + .card,
#order-panel .card + .card,
#edit-panel .card + .card {
  margin-top: 12px;
}

.label {
  font-weight: 600;
}

input[type="text"],
input[type="file"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: "Noto Serif TC", "PingFang TC", "Microsoft JhengHei", serif;
}

button {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 12px 14px;
  border-radius: 10px;
  font-weight: 600;
}

.ghost-btn {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 999px;
  padding: 6px 12px;
  font-weight: 600;
}

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

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

.category {
  display: grid;
  gap: 8px;
}

.category h3 {
  margin: 8px 0 0;
  font-size: 16px;
  color: var(--accent);
}

.category-items {
  display: grid;
  gap: 12px;
}

.item {
  background: #fbfaf7;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  display: grid;
  gap: 8px;
}

.item-btn {
  text-align: left;
  cursor: pointer;
  background: #fbfaf7;
  color: var(--text);
  border: 1px solid var(--border);
}

.item-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.item-left {
  display: grid;
}

.item-right {
  min-width: 64px;
  text-align: right;
  color: var(--accent);
  font-weight: 600;
}

.name-zh {
  font-weight: 600;
  margin-right: 8px;
}

.name-original {
  display: none;
  color: var(--muted);
  margin-top: 4px;
}

.show-original .name-original {
  display: block;
  font-size: 12px;
}

.price {
  color: var(--accent);
  font-weight: 600;
  margin-left: 6px;
}


.qty {
  display: flex;
  align-items: center;
  gap: 6px;
}

.qty-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.qty-value {
  min-width: 24px;
  text-align: center;
}

.actions {
  margin-top: 16px;
}

.top-actions {
  margin-bottom: 12px;
  display: flex;
  gap: 0;
}

.actions + form,
.actions + .card,
.actions + #order-form {
  margin-top: 12px;
}

.result {
  margin-top: 16px;
  color: var(--accent);
  word-break: break-all;
}

.tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
  white-space: nowrap;
}

.tab-toggle {
  position: relative;
  border: 1px solid var(--border);
  border-bottom: none;
  background: #f9f6ee;
  color: var(--text);
  padding: 10px 14px 8px;
  font-weight: 700;
  border-radius: 12px 12px 0 0;
  box-shadow: 0 -2px 6px rgba(0, 0, 0, 0.05) inset;
}

.tab-toggle:first-child {
  margin-right: 6px;
}

.tab-toggle.active {
  background: var(--card);
  border-color: var(--border);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.top-actions::after {
  content: "";
  flex: 1;
  border-bottom: 1px solid var(--border);
  align-self: flex-end;
  margin-left: 8px;
}

#toggle-original {
  margin-left: 8px;
}

.tab {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 999px;
  padding: 6px 12px;
  font-weight: 600;
  color: var(--text);
  flex: 0 0 auto;
}

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

.selected-panel {
  position: fixed;
  right: 16px;
  bottom: 16px;
  width: min(320px, 90vw);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  padding: 12px;
  display: grid;
  gap: 8px;
  z-index: 20;
}

.hidden {
  display: none;
}

.selected-panel.collapsed .selected-list {
  display: none;
}

.selected-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
}

.selected-panel .selected-list {
  max-height: 220px;
  overflow-y: auto;
}

.selected {
  margin-top: 12px;
}

.selected-list {
  display: grid;
  gap: 8px;
  font-size: 14px;
}

.selected-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 6px 8px;
  border-radius: 8px;
  background: #f7f4ec;
}

.remove-btn {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 8px;
  padding: 4px 8px;
  color: var(--text);
  font-weight: 600;
}

.image-grid {
  display: grid;
  gap: 8px;
}

.image-grid img {
  width: 100%;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.raw-text summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 600;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 16px;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: #fff;
  border-radius: 12px;
  max-width: 720px;
  width: 100%;
  padding: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  max-height: 80vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.item-modal-body {
  display: grid;
  gap: 12px;
}

.summary-text {
  white-space: pre-wrap;
  font-family: "Noto Serif TC", "PingFang TC", "Microsoft JhengHei", serif;
  color: var(--text);
}

.summary-table {
  display: grid;
  gap: 12px;
  font-size: 14px;
}

.summary-title + .summary-user-list,
.summary-user-list + .summary-title,
.summary-title + table {
  margin-top: 8px;
}

.summary-user-list {
  display: grid;
  gap: 12px;
}

.summary-user-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  background: #fbfaf7;
  display: grid;
  gap: 8px;
}

.summary-user-name {
  font-weight: 700;
}

.summary-user-items {
  border-top: 1px dashed var(--border);
  border-bottom: 1px dashed var(--border);
  padding: 8px 0;
}

.summary-user-total {
  text-align: right;
  font-weight: 600;
  color: var(--accent);
}

.summary-title {
  font-weight: 700;
  color: var(--accent);
}

.summary-table table {
  width: 100%;
  border-collapse: collapse;
}

.summary-table th,
.summary-table td {
  text-align: left;
  border-bottom: 1px solid var(--border);
  padding: 8px 6px;
  vertical-align: top;
}

.summary-total {
  text-align: right;
  font-weight: 700;
  color: var(--accent);
}

.summary-items {
  display: grid;
  gap: 6px;
}

.summary-item-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

@media (max-width: 520px) {
  .container {
    padding: 16px;
  }
}
