/* ── Variables ─────────────────────────────────────────────── */
:root {
  --primary:       #1d4ed8;
  --primary-dark:  #1e40af;
  --bg:            #f1f5f9;
  --card:          #ffffff;
  --text:          #1e293b;
  --sub:           #64748b;
  --border:        #e2e8f0;
  --warn-bg:       #fef9c3;
  --warn-border:   #eab308;
  --info-bg:       #eff6ff;
  --info-border:   #3b82f6;
  --shadow:        0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md:     0 4px 12px rgba(0,0,0,.08);
  --radius:        12px;
}

/* ── Reset & Base ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Sarabun', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.7;
  min-height: 100vh;
}

h1 { font-size: 1.5rem; font-weight: 700; }
h2 { font-size: 1.2rem; font-weight: 600; margin-bottom: .5rem; }
h3 { font-size: 1rem;   font-weight: 600; margin-bottom: .4rem; }
p  { margin-bottom: .6rem; }
ol, ul { padding-left: 1.4rem; }
ol li, ul li { margin-bottom: .35rem; }

a { color: var(--primary); }

code {
  background: #f1f5f9;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: .9em;
  font-family: monospace;
}

kbd {
  display: inline-block;
  background: #e2e8f0;
  border: 1px solid #94a3b8;
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 1px 8px;
  font-size: .85em;
  font-family: monospace;
  font-weight: 600;
  color: #334155;
  white-space: nowrap;
}

/* ── Layout ────────────────────────────────────────────────── */
.container {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  border: none;
  border-radius: 8px;
  padding: .55rem 1.2rem;
  font-family: inherit;
  font-size: .95rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, opacity .15s;
  text-decoration: none;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }

.btn-ghost {
  background: transparent;
  color: var(--sub);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg); }

.btn-full { width: 100%; justify-content: center; }

.btn-download {
  background: #16a34a;
  color: #fff;
  width: 100%;
  justify-content: center;
  margin-top: auto;
}
.btn-download:hover { background: #15803d; }

/* ── Login Page ────────────────────────────────────────────── */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
}

.login-container { width: 100%; max-width: 380px; }

.login-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 2.5rem 2rem;
  text-align: center;
}

.login-logo {
  color: var(--primary);
  margin-bottom: 1rem;
}

.login-card h1 { margin-bottom: .25rem; }

.login-subtitle {
  color: var(--sub);
  margin-bottom: 1.5rem;
  font-size: .95rem;
}

.input-group {
  position: relative;
  margin-bottom: .75rem;
}
.input-group input {
  width: 100%;
  padding: .65rem 3rem .65rem .9rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 1rem;
  outline: none;
  transition: border-color .15s;
}
.input-group input:focus { border-color: var(--primary); }

.toggle-pw {
  position: absolute;
  right: .7rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--sub);
  padding: .2rem;
  display: flex;
  align-items: center;
}
.toggle-pw:hover { color: var(--text); }

.error-msg {
  background: #fee2e2;
  color: #dc2626;
  border-radius: 7px;
  padding: .5rem .8rem;
  font-size: .9rem;
  margin-bottom: .75rem;
  text-align: left;
}

/* ── Header ────────────────────────────────────────────────── */
.site-header {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: var(--shadow);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .8rem 0;
}

.site-title {
  font-size: 1.05rem;
  font-weight: 700;
}

/* ── Tabs ──────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: .5rem;
  margin: 1.5rem 0 1rem;
  border-bottom: 2px solid var(--border);
}

.tab {
  background: none;
  border: none;
  padding: .6rem 1.2rem;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 500;
  color: var(--sub);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  border-radius: 4px 4px 0 0;
  transition: color .15s, border-color .15s;
}
.tab:hover { color: var(--primary); }
.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab-content { display: none; padding-bottom: 3rem; }
.tab-content.active { display: block; }

/* ── Step Cards ────────────────────────────────────────────── */
.step-card {
  display: flex;
  gap: 1.2rem;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  border-left: 4px solid transparent;
}

.step-card.important {
  border-left-color: #f59e0b;
}

.step-number {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 700;
  margin-top: .05rem;
}

.step-card.important .step-number { background: #f59e0b; }

.step-body { flex: 1; min-width: 0; }
.step-body h2 { margin-top: .1rem; }

/* ── Alert Boxes ───────────────────────────────────────────── */
.alert {
  border-radius: 8px;
  padding: .75rem 1rem;
  margin: .75rem 0;
  font-size: .95rem;
  border-left: 4px solid;
}
.alert-warning {
  background: var(--warn-bg);
  border-color: var(--warn-border);
  color: #78350f;
}
.alert-info {
  background: var(--info-bg);
  border-color: var(--info-border);
  color: #1e40af;
}

/* ── BIOS Table ────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  margin: .75rem 0 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.bios-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .95rem;
}
.bios-table th {
  background: #f8fafc;
  padding: .6rem .9rem;
  text-align: left;
  font-weight: 600;
  color: var(--sub);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.bios-table td {
  padding: .6rem .9rem;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}
.bios-table tr:last-child td { border-bottom: none; }
.bios-table tr:nth-child(even) td { background: #f8fafc; }

/* ── BIOS Images Grid ──────────────────────────────────────── */
.bios-images {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: .75rem;
  margin-top: 1rem;
}
.bios-images figure {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: #f8fafc;
}
.bios-images figure img {
  width: 100%;
  display: block;
  max-height: 130px;
  object-fit: cover;
}
.bios-images figcaption {
  padding: .35rem .6rem;
  font-size: .82rem;
  color: var(--sub);
  text-align: center;
  border-top: 1px solid var(--border);
}

/* ── Key Download Grid ─────────────────────────────────────── */
.key-download-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.key-card {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.2rem 1rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  text-align: center;
}

.key-label {
  font-size: 2rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
}

.key-card p {
  font-size: .85rem;
  color: var(--sub);
  margin: 0;
  flex: 1;
}

/* ── Password Display ──────────────────────────────────────── */
.password-display {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.2rem;
  margin-top: .75rem;
}

.password-label {
  font-size: .85rem;
  color: var(--sub);
  margin-bottom: .4rem;
  font-weight: 500;
}

.password-value {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
}

.pw-text {
  font-family: monospace;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: .05em;
  word-break: break-all;
  flex: 1;
}
.pw-text.masked { letter-spacing: .15em; }

.btn-show-pw {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: .3rem .8rem;
  font-family: inherit;
  font-size: .85rem;
  cursor: pointer;
  white-space: nowrap;
}
.btn-show-pw:hover { background: var(--primary-dark); }

.btn-copy {
  background: #e2e8f0;
  color: var(--text);
  border: none;
  border-radius: 6px;
  padding: .3rem .8rem;
  font-family: inherit;
  font-size: .85rem;
  cursor: pointer;
  white-space: nowrap;
}
.btn-copy:hover { background: #cbd5e1; }
.btn-copy.copied { background: #dcfce7; color: #16a34a; }

/* ── Mini Steps (for Change BitLocker / Windows) ───────────── */
.steps-mini { display: flex; flex-direction: column; gap: 1rem; margin-top: .75rem; }

.step-mini {
  display: flex;
  gap: .8rem;
  align-items: flex-start;
}

.mini-num {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  background: #e2e8f0;
  color: var(--text);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .82rem;
  font-weight: 700;
  margin-top: .15rem;
}

.step-mini p { margin: 0 0 .4rem; }

.field-hint {
  display: block;
  color: var(--sub);
  font-size: .88rem;
  margin-top: .15rem;
}

.step-mini img {
  width: 100%;
  max-width: 480px;
  border-radius: 6px;
  border: 1px solid var(--border);
  display: block;
}

/* ── Image Wrap ────────────────────────────────────────────── */
.img-wrap {
  margin: .75rem 0;
}
.img-wrap img {
  width: 100%;
  max-width: 540px;
  border-radius: 8px;
  border: 1px solid var(--border);
  display: block;
}

/* ── USB Name Badge ────────────────────────────────────────── */
.usb-name-badge {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  background: #1e293b;
  color: #e2e8f0;
  font-family: monospace;
  font-size: .9rem;
  padding: .55rem 1rem;
  border-radius: 7px;
  margin: .5rem 0 .75rem;
  word-break: break-all;
}

/* ── Key Reveal ────────────────────────────────────────────── */
.key-reveal-grid {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: .75rem;
}

.key-reveal-card {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.1rem;
}

.btn-show-key {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  background: #1d4ed8;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: .6rem 1.1rem;
  font-family: inherit;
  font-size: .95rem;
  font-weight: 500;
  cursor: pointer;
  width: 100%;
  justify-content: center;
  margin-top: .4rem;
  transition: background .15s;
}
.btn-show-key:hover:not(:disabled) { background: var(--primary-dark); }
.btn-show-key:disabled { opacity: .55; cursor: not-allowed; }

.key-content {
  margin-top: .85rem;
  background: #fff;
  border: 1.5px solid #3b82f6;
  border-radius: 10px;
  overflow: hidden;
}

.key-section {
  padding: .9rem 1rem;
  border-bottom: 1px solid #e2e8f0;
}
.key-section:last-child { border-bottom: none; }

.key-section-label {
  font-weight: 600;
  font-size: .9rem;
  color: #1e40af;
  margin-bottom: .3rem;
}

.key-note {
  font-size: .82rem;
  color: #64748b;
  margin-bottom: .5rem;
  line-height: 1.5;
}

.key-identifier {
  font-family: monospace;
  font-size: .95rem;
  color: #475569;
  letter-spacing: .03em;
  word-break: break-all;
  background: #f1f5f9;
  border-radius: 6px;
  padding: .4rem .6rem;
}

.key-number {
  font-family: monospace;
  font-size: 1.2rem;
  font-weight: 700;
  color: #1e293b;
  letter-spacing: .05em;
  word-break: break-all;
  line-height: 1.9;
  margin-bottom: .75rem;
}

.btn-copy-key {
  background: #16a34a;
  color: #fff;
  border: none;
  border-radius: 7px;
  padding: .55rem 1.1rem;
  font-family: inherit;
  font-size: .9rem;
  font-weight: 500;
  cursor: pointer;
  width: 100%;
  transition: background .15s;
}
.btn-copy-key:hover { background: #15803d; }
.btn-copy-key.copied { background: #166534; }

/* ── Responsive — Mobile First ─────────────────────────────── */
@media (max-width: 640px) {
  body { font-size: 15px; }

  .container { padding: 0 .75rem; }

  .site-title { font-size: .95rem; }
  .btn.btn-ghost { padding: .4rem .75rem; font-size: .85rem; }

  .tab { padding: .55rem .8rem; font-size: .9rem; }

  .step-card {
    flex-direction: column;
    padding: 1.1rem;
    gap: .75rem;
  }
  .step-number { width: 34px; height: 34px; font-size: 1rem; }

  h2 { font-size: 1.05rem; }
  h3 { font-size: .95rem; }

  .bios-table { font-size: .85rem; }
  .bios-table th, .bios-table td { padding: .45rem .6rem; }

  kbd { font-size: .78rem; padding: 1px 6px; }

  .password-value { gap: .4rem; }
  .pw-text { font-size: 1rem; }

  .key-number { font-size: 1rem; letter-spacing: .02em; }

  .steps-mini { gap: .85rem; }
  .step-mini img { max-width: 100%; }

  .usb-name-badge { font-size: .78rem; }
}
