/* Codes Tool Box — shared shell + tools */
:root {
  --ink: #14181f;
  --ink-soft: #2a3140;
  --muted: #5e6778;
  --line: #d5dae3;
  --line-soft: #e8ebf1;
  --bg: #eef1f6;
  --card: #ffffff;
  --codes: #c8102e;
  --codes-deep: #9a0c22;
  --ok: #0f7a55;
  --ok-bg: #e8f7f1;
  --err: #b42318;
  --err-bg: #fef2f2;
  --warn: #9a5b00;
  --warn-bg: #fff6e5;
  --accent: #1f4b99;
  --hktv: #e31837;
  --yoho: #0b6e4f;
  --radius: 16px;
  --radius-sm: 10px;
  --tap: 48px;
  --shadow: 0 10px 30px rgba(20, 24, 31, 0.06);
  --font: "Sora", system-ui, sans-serif;
  --display: "Fraunces", Georgia, serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(ellipse 90% 55% at 0% -10%, rgba(200, 16, 46, 0.10), transparent 55%),
    radial-gradient(ellipse 70% 45% at 100% 0%, rgba(31, 75, 153, 0.08), transparent 50%),
    linear-gradient(180deg, #f7f8fb 0%, var(--bg) 40%, #e9edf4 100%);
  background-attachment: fixed;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.35;
  background-image:
    linear-gradient(rgba(20, 24, 31, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(20, 24, 31, 0.03) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: radial-gradient(ellipse 80% 70% at 50% 20%, #000 20%, transparent 75%);
}

.app {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 64px;
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 22px;
  position: relative;
  z-index: 1;
}

@media (max-width: 860px) {
  .app {
    grid-template-columns: 1fr;
    width: min(720px, calc(100% - 24px));
    padding-top: 18px;
  }
}

/* —— Sidebar —— */
.sidebar {
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(12px);
  border: 1.5px solid var(--line);
  border-radius: 22px;
  padding: 20px 16px;
  box-shadow: var(--shadow);
  height: fit-content;
  position: sticky;
  top: 16px;
  animation: rise 0.55s ease both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.brand {
  padding: 4px 8px 18px;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 14px;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.brand-dot {
  width: 12px;
  height: 12px;
  border-radius: 4px;
  background: var(--codes);
  box-shadow: 0 0 0 4px rgba(200, 16, 46, 0.15);
}

.brand h1 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.55rem;
  font-weight: 650;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.brand p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.4;
}

.nav-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 8px 10px 6px;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav-btn {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 10px;
  align-items: center;
  width: 100%;
  text-align: left;
  border: 1.5px solid transparent;
  background: transparent;
  border-radius: 14px;
  padding: 10px;
  cursor: pointer;
  font: inherit;
  color: var(--ink);
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

.nav-btn:hover { background: #f4f6fa; }
.nav-btn:active { transform: scale(0.99); }

.nav-btn.active {
  background: #fff;
  border-color: var(--line);
  box-shadow: 0 4px 14px rgba(20, 24, 31, 0.05);
}

.nav-icon {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  font-size: 0.95rem;
  font-weight: 700;
  background: #eef2f8;
  color: var(--ink-soft);
}

.nav-btn.active .nav-icon {
  background: rgba(200, 16, 46, 0.12);
  color: var(--codes-deep);
}

.nav-btn strong {
  display: block;
  font-size: 0.92rem;
  font-weight: 700;
}

.nav-btn span {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 2px;
  line-height: 1.3;
}

.nav-btn.soon {
  opacity: 0.55;
  cursor: default;
}

.nav-btn.soon:hover { background: transparent; }

.sidebar-foot {
  margin-top: 16px;
  padding: 12px 10px 4px;
  border-top: 1px solid var(--line-soft);
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.45;
}

.lang-toggle {
  display: inline-flex;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
  background: var(--card);
  margin-top: 10px;
}

.lang-toggle button {
  border: none;
  background: transparent;
  padding: 7px 12px;
  font: inherit;
  font-weight: 700;
  font-size: 0.75rem;
  cursor: pointer;
  color: var(--muted);
}

.lang-toggle button.active {
  background: var(--ink);
  color: #fff;
}

/* —— Main —— */
.main {
  min-width: 0;
  animation: rise 0.55s ease 0.08s both;
}

.tool-panel {
  display: none;
}

.tool-panel.active {
  display: block;
  animation: panelIn 0.35s ease both;
}

@keyframes panelIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.panel-head {
  margin-bottom: 18px;
}

.panel-head h2 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(1.45rem, 3vw, 1.9rem);
  font-weight: 650;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.panel-head p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.5;
  max-width: 52ch;
}

.card {
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

.card + .card { margin-top: 14px; }

.field-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 8px;
}

.field-label .req {
  color: var(--codes);
  margin-left: 4px;
}

input[type="text"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  font: inherit;
  font-size: 0.95rem;
  line-height: 1.45;
  background: #fff;
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

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

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 75, 153, 0.14);
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

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

@media (max-width: 640px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.btn {
  min-height: var(--tap);
  border: none;
  border-radius: 12px;
  padding: 12px 16px;
  font: inherit;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.btn:active:not(:disabled) { transform: scale(0.98); }
.btn:disabled { opacity: 0.35; cursor: not-allowed; }

.btn-primary { background: var(--ink); color: #fff; }
.btn-codes { background: var(--codes); color: #fff; }
.btn-codes:hover { background: var(--codes-deep); }
.btn-secondary {
  background: #fff;
  color: var(--ink);
  border: 1.5px solid var(--line);
}
.btn-ok { background: var(--ok); color: #fff; }
.btn-accent { background: var(--accent); color: #fff; }
.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1.5px dashed var(--line);
}

.status {
  margin: 10px 0 0;
  font-size: 0.9rem;
  min-height: 1.3em;
}
.status.error { color: var(--err); }
.status.info { color: var(--muted); }
.status.ok { color: var(--ok); }

.section-title {
  margin: 22px 0 10px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.empty-state {
  padding: 22px;
  text-align: center;
  color: var(--muted);
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  background: rgba(255,255,255,0.55);
}

.hidden { display: none !important; }

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  border: 1.5px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 8px 12px;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 650;
  cursor: pointer;
  color: var(--ink-soft);
}

.chip.active {
  border-color: var(--codes);
  background: rgba(200, 16, 46, 0.08);
  color: var(--codes-deep);
}

.hint-box {
  padding: 12px 14px;
  border-radius: 12px;
  background: #f4f6fa;
  border: 1px solid var(--line-soft);
  font-size: 0.85rem;
  color: var(--ink-soft);
  line-height: 1.45;
}

.hint-box.warn {
  background: var(--warn-bg);
  border-color: #f0d9a8;
  color: var(--warn);
}

.hint-box.ok {
  background: var(--ok-bg);
  border-color: #b7e4d0;
  color: var(--ok);
}

.defaults-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 8px;
}

.default-pill {
  background: #f7f8fb;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  padding: 8px 10px;
}

.default-pill small {
  display: block;
  font-size: 0.68rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.default-pill strong {
  display: block;
  margin-top: 2px;
  font-size: 0.82rem;
  font-family: var(--mono);
  word-break: break-all;
}

/* Steps */
.steps {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.step-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
}

.step-pill .n {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #eef2f8;
  font-size: 0.72rem;
}

.step-pill.active {
  border-color: var(--ink);
  color: var(--ink);
}

.step-pill.active .n {
  background: var(--ink);
  color: #fff;
}

.step-pill.done {
  border-color: #b7e4d0;
  color: var(--ok);
}

.step-pill.done .n {
  background: var(--ok);
  color: #fff;
}

.step-panel { display: none; }
.step-panel.active { display: block; }

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

.check-list li {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line-soft);
  background: #fafbfd;
  font-size: 0.88rem;
  line-height: 1.4;
}

.check-list li.missing {
  background: var(--err-bg);
  border-color: #fecaca;
  color: var(--err);
}

.check-list li.ok-item {
  background: var(--ok-bg);
  border-color: #b7e4d0;
}

/* Output blocks */
.out-block {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: #fafbfd;
  display: grid;
  gap: 8px;
}

.out-block + .out-block { margin-top: 10px; }

.out-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.out-head h3 {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 700;
}

.len-badge {
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 999px;
  background: #eef2f8;
  color: var(--ink-soft);
}

.len-badge.over {
  background: var(--err-bg);
  color: var(--err);
}

.len-badge.good {
  background: var(--ok-bg);
  color: var(--ok);
}

.out-body {
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  max-height: 220px;
  overflow: auto;
}

.copy {
  min-width: 88px;
  min-height: 40px;
  border: none;
  border-radius: 10px;
  padding: 0 14px;
  font: inherit;
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  background: var(--ink);
  color: #fff;
}

.copy.copied { background: var(--ok); }

/* YT tool leftovers */
.results { display: grid; gap: 14px; }

.item {
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  display: grid;
  gap: 12px;
}

.item-top {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 12px;
  align-items: start;
}

@media (max-width: 520px) {
  .item-top { grid-template-columns: 96px 1fr; }
}

.thumb-wrap {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  background: #e8ecf4;
  aspect-ratio: 16 / 9;
}

.thumb-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.meta { display: grid; gap: 8px; min-width: 0; }

.source-line {
  font-size: 0.8rem;
  color: var(--muted);
  word-break: break-all;
  line-height: 1.35;
}

.tags { display: flex; flex-wrap: wrap; gap: 6px; }

.tag {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 4px 8px;
  border-radius: 999px;
}

.tag.shorts {
  background: var(--warn-bg);
  color: var(--warn);
  border: 1px solid #fdba74;
}

.tag.ok {
  background: var(--ok-bg);
  color: var(--ok);
  border: 1px solid #a7f3d0;
}

.tag.bad {
  background: var(--err-bg);
  color: var(--err);
  border: 1px solid #fecaca;
}

.out-grid { display: grid; gap: 10px; }

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

.out-card.pulse {
  box-shadow: 0 0 0 3px rgba(11, 110, 79, 0.25);
  border-color: var(--yoho);
}

.badge {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 4px 9px;
  border-radius: 999px;
  color: #fff;
}

.badge.hktv { background: var(--hktv); }
.badge.yoho { background: var(--yoho); }

.hint { font-size: 0.75rem; color: var(--muted); }

.value-row { display: flex; gap: 8px; align-items: stretch; }

.value {
  flex: 1;
  min-width: 0;
  padding: 12px;
  border-radius: 10px;
  background: #fff;
  border: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 0.88rem;
  word-break: break-all;
  line-height: 1.4;
  display: flex;
  align-items: center;
}

.copy.next-target {
  background: var(--yoho);
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(11, 110, 79, 0.45); }
  50% { box-shadow: 0 0 0 6px rgba(11, 110, 79, 0); }
}

.next-hint {
  display: none;
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  color: #312e81;
  font-size: 0.92rem;
  font-weight: 600;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.next-hint.show { display: flex; flex-wrap: wrap; }

.batch-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.history-list { display: grid; gap: 8px; margin-top: 10px; }

.history-item {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fafbfd;
  cursor: pointer;
  text-align: left;
  width: 100%;
  font: inherit;
}

.history-item:hover { border-color: #a5b4fc; }

.history-item img {
  width: 72px;
  height: 40px;
  object-fit: cover;
  border-radius: 6px;
  background: #e8ecf4;
  flex-shrink: 0;
}

.history-meta { min-width: 0; flex: 1; }

.history-meta strong {
  display: block;
  font-size: 0.88rem;
  font-family: var(--mono);
}

.history-meta span {
  font-size: 0.75rem;
  color: var(--muted);
}

.qr-panel {
  display: grid;
  gap: 12px;
  justify-items: center;
  text-align: center;
}

.qr-panel img {
  width: min(200px, 70vw);
  height: auto;
  border-radius: 12px;
  background: #fff;
  border: 1px solid var(--line);
  padding: 10px;
}

.qr-url {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--muted);
  word-break: break-all;
}

footer.tool-foot {
  margin-top: 20px;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.5;
}

.sku-row {
  display: grid;
  grid-template-columns: 1.2fr 1fr 90px 40px;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

@media (max-width: 640px) {
  .sku-row { grid-template-columns: 1fr 1fr; }
}

.dropzone {
  border: 1.5px dashed var(--line);
  border-radius: 14px;
  padding: 16px;
  background: #f7f8fb;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.dropzone:hover, .dropzone.drag {
  border-color: var(--codes);
  background: rgba(200, 16, 46, 0.04);
}

.dropzone strong {
  display: block;
  font-size: 0.9rem;
  margin-bottom: 4px;
}

.dropzone span {
  font-size: 0.78rem;
  color: var(--muted);
}

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

.photo-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: #fff;
  display: grid;
  gap: 10px;
}

.photo-card h4 {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 700;
}

.photo-previews {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.photo-thumb {
  position: relative;
  width: 88px;
  height: 88px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #eef2f8;
}

.photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.photo-thumb button {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 50%;
  background: rgba(20, 24, 31, 0.75);
  color: #fff;
  font-size: 0.85rem;
  cursor: pointer;
  line-height: 1;
}

.photo-thumb .fname {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 2px 4px;
  font-size: 0.55rem;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  word-break: break-all;
  line-height: 1.2;
}
