:root {
  --bg: #0e0f10;
  --panel: #161718;
  --box: #262626;
  --row: rgba(42, 42, 42, 0.3);
  --line: rgba(255, 255, 255, 0.08);
  --text: #ffffff;
  --muted: #9c9c9c;
  --dim: #737373;
  --accent: #73efff;
  --accent-soft: rgba(115, 239, 255, 0.14);
  --accent-line: rgba(115, 239, 255, 0.27);
  --red: #ff7373;
  --radius: 9px;
  --font: 'Inter', 'Noto Sans Thai', system-ui, sans-serif;
}

* { box-sizing: border-box; }

html { background: var(--bg); }

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(1200px 500px at 50% -200px, rgba(115, 239, 255, 0.06), transparent), var(--bg);
  color: var(--text);
  font: 14px/1.6 var(--font);
}

[hidden] { display: none !important; }

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

a { color: inherit; }

code {
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--box);
  font: 12px/1.6 ui-monospace, Consolas, monospace;
}

.page {
  max-width: 1040px;
  margin: 0 auto;
  padding: 48px 16px 80px;
  display: grid;
  gap: 16px;
}

/* ---------- header ---------- */

.top {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 8px;
}

.mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  flex: none;
}

.mark i {
  width: 24px;
  height: 24px;
  border: 2px solid var(--accent);
  border-radius: 4px;
  transform: rotate(45deg);
  box-shadow: 0 0 16px var(--accent-line), inset 0 0 8px var(--accent-line);
}

.top h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.sub {
  color: var(--muted);
  font-size: 13px;
}

/* ---------- panels ---------- */

.panel {
  padding: 24px;
  background: var(--panel);
  border-radius: 12px;
  clip-path: polygon(0 0, calc(100% - 18px) 0, 100% 18px, 100% 100%, 0 100%);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

.panel h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 12px;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.tab {
  padding: 7px 16px;
  border: 0;
  border-radius: 999px;
  background: rgba(136, 136, 136, 0.14);
  color: var(--muted);
  font: 500 13px var(--font);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.tab:hover { color: var(--text); }

.tab.is-active {
  background: var(--accent);
  color: #0b1b1d;
}

.mode { display: none; }
.mode.is-active { display: grid; gap: 12px; }

.row {
  display: flex;
  gap: 12px;
}

.row--end { justify-content: flex-end; }

.input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--box);
  color: var(--text);
  font: 14px var(--font);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input:focus {
  border-color: var(--accent-line);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

textarea.input {
  resize: vertical;
  font: 13px/1.5 ui-monospace, Consolas, monospace;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border: 0;
  border-radius: var(--radius);
  background: rgba(136, 136, 136, 0.14);
  color: var(--text);
  font: 600 14px var(--font);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}

.btn:hover { background: rgba(136, 136, 136, 0.24); }

.btn--primary {
  background: var(--accent);
  color: #0b1b1d;
}

.btn--primary:hover { background: #a3f5ff; }

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn--small {
  padding: 6px 12px;
  font-size: 12px;
}

.hint {
  color: var(--dim);
  font-size: 12px;
}

.error {
  margin-top: 12px;
  color: var(--red);
  font-size: 13px;
}

/* ---------- upload ---------- */

.drop {
  display: grid;
  gap: 4px;
  justify-items: center;
  padding: 36px 16px;
  border: 1px dashed rgba(255, 255, 255, 0.18);
  border-radius: var(--radius);
  background: var(--row);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.drop:hover,
.drop.is-over {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.drop span {
  color: var(--muted);
  font-size: 12px;
}

.drop em {
  margin-top: 8px;
  color: var(--accent);
  font-style: normal;
  font-weight: 600;
}

.advanced {
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--row);
}

.advanced summary {
  cursor: pointer;
  font-weight: 500;
}

.advanced summary span {
  margin-left: 6px;
  color: var(--dim);
  font-size: 12px;
  font-weight: 400;
}

.advanced p {
  margin: 8px 0;
  color: var(--muted);
  font-size: 12px;
}

/* ---------- status ---------- */

.status {
  display: flex;
  align-items: center;
  gap: 16px;
}

.status strong { font-size: 15px; }

.status--failed {
  justify-content: space-between;
  border-left: 3px solid var(--red);
}

.spinner {
  width: 28px;
  height: 28px;
  flex: none;
  border: 3px solid var(--accent-soft);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- result ---------- */

.result-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
}

.result-head h2 {
  font-size: 18px;
  font-weight: 600;
  word-break: break-word;
}

.result-head .sub { word-break: break-all; }

.actions {
  display: flex;
  gap: 8px;
  flex: none;
}

.swatches {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}

.swatch {
  overflow: hidden;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--box);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.swatch__color { height: 64px; }

.swatch__info {
  display: grid;
  padding: 8px 12px 10px;
}

.swatch__info b {
  font: 600 13px ui-monospace, Consolas, monospace;
}

.swatch__info span {
  color: var(--muted);
  font-size: 12px;
}

.palette {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
}

.chip {
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
}

.facts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  margin: 16px 0 0;
}

.facts div {
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--row);
}

.facts dt {
  color: var(--dim);
  font-size: 12px;
}

.facts dd {
  margin: 0;
  font-weight: 600;
  word-break: break-word;
}

.view iframe {
  width: 100%;
  height: 680px;
  border: 0;
  border-radius: var(--radius);
  background: #ffffff;
}

.md-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.md {
  max-height: 680px;
  overflow: auto;
  margin: 0;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--bg);
  color: #d6d6d6;
  font: 12px/1.6 ui-monospace, Consolas, monospace;
  white-space: pre-wrap;
  word-break: break-word;
}

.shot {
  max-height: 680px;
  overflow: auto;
  border-radius: var(--radius);
  background: var(--bg);
}

.shot img {
  display: block;
  width: 100%;
}

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

.file {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--row);
}

.file__name {
  display: grid;
  flex: 1;
  min-width: 0;
}

.file__name b {
  font-weight: 500;
}

.file__name span {
  overflow: hidden;
  color: var(--dim);
  font: 12px ui-monospace, Consolas, monospace;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file__size {
  color: var(--dim);
  font-size: 12px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  padding: 10px 18px;
  border-radius: var(--radius);
  background: var(--accent);
  color: #0b1b1d;
  font-weight: 600;
  transform: translate(-50%, 16px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}

.toast.is-shown {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 640px) {
  .page { padding-top: 24px; }
  .panel { padding: 18px; }
  .row { flex-direction: column; }
  .result-head { flex-direction: column; }
  .actions { width: 100%; }
  .actions .btn { flex: 1; }
  .view iframe { height: 520px; }
  .file__size { display: none; }
}
