@font-face {
  font-family: "LINE Seed Sans TH";
  src: url("/assets/fonts/line-seed-sans-th-v1.003/LINESeedSansTH_W_Rg.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "LINE Seed Sans TH";
  src: url("/assets/fonts/line-seed-sans-th-v1.003/LINESeedSansTH_W_Bd.woff2") format("woff2");
  font-style: normal;
  font-weight: 700;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --bg: #09090f;
  --surface: #15151f;
  --surface-soft: #1b1b27;
  --line: rgba(255, 255, 255, 0.1);
  --text: #f7f7fb;
  --muted: #a8a8b8;
  --accent: #de2b9d;
  --accent-hover: #ec48b1;
  --success: #45d18c;
  --success-bg: rgba(69, 209, 140, 0.1);
  --success-line: rgba(69, 209, 140, 0.2);
  --warning: #ffbf5b;
  --warning-bg: rgba(255, 191, 91, 0.1);
  --warning-line: rgba(255, 191, 91, 0.2);
  --repair: #b9b1ff;
  --repair-bg: rgba(98, 56, 240, 0.12);
  --repair-line: rgba(98, 56, 240, 0.24);
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.16);
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #f7f7f9;
  --surface: #ffffff;
  --surface-soft: #f1f2f5;
  --line: #e2e3e8;
  --text: #191a20;
  --muted: #686b76;
  --accent: #c52e88;
  --accent-hover: #aa226f;
  --success: #167b4b;
  --success-bg: #eaf6ef;
  --success-line: #cae8d7;
  --warning: #9a5b00;
  --warning-bg: #fff5e6;
  --warning-line: #f0dbb9;
  --repair: #5145a8;
  --repair-bg: #f0eefb;
  --repair-line: #dcd7f4;
  --shadow: 0 2px 8px rgba(24, 25, 31, 0.04);
}

* { box-sizing: border-box; }

html { min-width: 320px; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "LINE Seed Sans TH", -apple-system, BlinkMacSystemFont, "SF Pro Text", sans-serif;
}

button, input { font: inherit; }
a { color: inherit; }

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(1120px, calc(100% - 36px));
  margin: 0 auto;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.history-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  color: var(--text);
  text-decoration: none;
}

.history-brand img { border-radius: 13px; }
.history-brand span { display: grid; line-height: 1.05; }
.history-brand strong { font-size: 15px; }
.history-brand small { margin-top: 5px; color: var(--muted); font-size: 10px; letter-spacing: .06em; }

.history-header nav { display: flex; align-items: center; gap: 14px; }
.history-header nav a { color: var(--muted); font-size: 13px; text-decoration: none; }
.history-header nav a:hover { color: var(--text); }

.history-main { width: min(840px, calc(100% - 36px)); margin: 46px auto 70px; }
h1 { margin: 0 0 24px; font-size: clamp(30px, 4vw, 40px); line-height: 1.25; letter-spacing: -.02em; }

.history-search {
  position: relative;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.history-search label { display: block; margin-bottom: 9px; font-size: 14px; font-weight: 700; }
.search-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; }

.search-row input {
  width: 100%;
  min-height: 54px;
  padding: 0 17px;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: 0;
  background: var(--bg);
  color: var(--text);
}

html[data-theme="light"] .search-row input { background: #fff; }
.search-row input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 12%, transparent); }
.search-row input[aria-invalid="true"] { border-color: #dc3f4f; }

.search-row button {
  min-height: 54px;
  padding: 0 24px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: white;
  font-weight: 700;
  cursor: pointer;
}

.search-row button:hover { background: var(--accent-hover); }
.search-row button:disabled { cursor: wait; opacity: .68; }
.form-message { min-height: 20px; margin: 10px 2px 0; color: var(--muted); font-size: 12px; }
.form-message.error { color: #dc3f4f; }

.website-field {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.history-results { margin-top: 40px; }
.results-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; }
.results-heading h2 { margin: 0; font-size: 24px; }
.results-heading p { margin: 0; color: var(--muted); font-size: 13px; }

.history-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 17px 0 28px; }
.history-summary div { padding: 17px 18px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.history-summary strong { display: block; font-size: 24px; }
.history-summary span { color: var(--muted); font-size: 12px; }

.result-section { margin-top: 30px; }
.result-section > h2 { margin: 0 0 13px; padding-left: 12px; border-left: 4px solid var(--accent); font-size: 18px; }
.history-list { display: grid; gap: 12px; }

.history-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 18px;
  align-items: center;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}

.history-card h3 { margin: 0 0 4px; font-size: 17px; }
.card-meta { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.65; }
.card-extra { margin-top: 4px; color: var(--text); }
.card-status { min-width: 175px; text-align: right; }
.badge { display: inline-flex; padding: 6px 10px; border: 1px solid; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge.active { border-color: var(--success-line); background: var(--success-bg); color: var(--success); }
.badge.expired { border-color: var(--warning-line); background: var(--warning-bg); color: var(--warning); }
.badge.repair { border-color: var(--repair-line); background: var(--repair-bg); color: var(--repair); }
.status-date { display: block; margin-top: 7px; color: var(--muted); font-size: 12px; }

.history-empty {
  margin-top: 28px;
  padding: 30px 24px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  text-align: center;
}
.history-empty h2 { margin: 0 0 8px; font-size: 21px; }
.history-empty p { max-width: 560px; margin: 0 auto 18px; color: var(--muted); line-height: 1.65; }
.history-empty a { color: var(--accent); font-weight: 700; }

.history-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  width: min(840px, calc(100% - 36px));
  margin: 0 auto;
  padding: 22px 0 34px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

[hidden] { display: none !important; }

@media (max-width: 620px) {
  .history-header, .history-main, .history-footer { width: min(100% - 28px, 480px); }
  .history-brand img { width: 40px; height: 40px; }
  .history-header nav { gap: 9px; }
  .history-header nav a { font-size: 12px; }
  .history-main { margin-top: 32px; }
  h1 { margin-bottom: 20px; font-size: 30px; }
  .history-search { padding: 16px; border-radius: 14px; }
  .search-row { grid-template-columns: 1fr; }
  .results-heading { display: block; }
  .results-heading p { margin-top: 5px; }
  .history-summary { gap: 7px; }
  .history-summary div { padding: 13px 10px; border-radius: 10px; }
  .history-summary strong { font-size: 20px; }
  .history-card { grid-template-columns: 1fr; gap: 12px; padding: 16px; border-radius: 12px; }
  .card-status { min-width: 0; text-align: left; }
  .history-footer { gap: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
