/* ==========================================================================
   HTML Code Security & Protection — style.css
   Modern glassmorphism / SaaS design · mobile-first · light + dark themes
   ========================================================================== */

/* ------------------------------- tokens ------------------------------- */
:root {
  color-scheme: dark;
  --bg-0: #070b18;
  --bg-1: #0d1226;
  --card: rgba(255, 255, 255, 0.055);
  --card-solid: #101731;
  --border: rgba(255, 255, 255, 0.1);
  --border-strong: rgba(255, 255, 255, 0.18);
  --text-0: #eef1fa;
  --text-1: #c4cbe0;
  --text-2: #8a93ad;
  --accent-0: #6366f1;
  --accent-1: #a855f7;
  --accent-grad: linear-gradient(135deg, #6366f1 0%, #8b5cf6 60%, #a855f7 100%);
  --ok: #34d399;
  --warn: #fbbf24;
  --danger: #fb7185;
  --code-bg: rgba(2, 6, 23, 0.75);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  --radius: 18px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

/* Light theme (follows the OS preference) */
@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg-0: #eef1fb;
    --bg-1: #e2e7f6;
    --card: rgba(255, 255, 255, 0.72);
    --card-solid: #ffffff;
    --border: rgba(15, 23, 42, 0.1);
    --border-strong: rgba(15, 23, 42, 0.2);
    --text-0: #0f172a;
    --text-1: #334155;
    --text-2: #64748b;
    --code-bg: #0f172a;
    --shadow: 0 18px 40px rgba(15, 23, 42, 0.12);
  }
}

/* ------------------------------- base -------------------------------- */
*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--text-0);
  background:
    radial-gradient(1100px 620px at 8% -8%, rgba(99, 102, 241, 0.16), transparent 60%),
    radial-gradient(950px 600px at 105% 12%, rgba(168, 85, 247, 0.13), transparent 60%),
    linear-gradient(165deg, var(--bg-0) 0%, var(--bg-1) 100%);
  background-attachment: fixed;
  line-height: 1.5;
}

a { color: #818cf8; }

:focus-visible {
  outline: 3px solid rgba(129, 140, 248, 0.85);
  outline-offset: 2px;
  border-radius: 6px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  padding: 10px 16px;
  background: var(--accent-0);
  color: #fff;
  border-radius: 0 0 10px 0;
  font-weight: 600;
}
.skip-link:focus { left: 0; color: #fff; }

.hidden { display: none !important; }

/* ------------------------------ header ------------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 22px;
  background: rgba(7, 11, 24, 0.72);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
@media (prefers-color-scheme: light) {
  .topbar { background: rgba(255, 255, 255, 0.72); }
}

.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand-logo { width: 34px; height: 34px; flex: 0 0 auto; }
.brand-name {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.2px;
  white-space: nowrap;
}
.brand-name em {
  font-style: normal;
  background: var(--accent-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand-tag {
  display: none;
  font-size: 11.5px;
  color: var(--text-2);
  border-left: 1px solid var(--border-strong);
  padding-left: 10px;
  margin-left: 2px;
  white-space: nowrap;
}
@media (min-width: 760px) { .brand-tag { display: inline-block; } }

.privacy-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 700;
  color: #a7f3d0;
  background: rgba(52, 211, 153, 0.12);
  border: 1px solid rgba(52, 211, 153, 0.35);
  border-radius: 999px;
  padding: 7px 13px;
  white-space: nowrap;
}
.privacy-badge .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.25);
}

/* ------------------------------ layout ------------------------------- */
.layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  padding: 18px;
  max-width: 1500px;
  margin: 0 auto;
}
@media (min-width: 1020px) {
  .layout { grid-template-columns: minmax(0, 1.35fr) minmax(360px, 0.85fr); align-items: start; }
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  overflow: hidden;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 15px 18px;
  border-bottom: 1px solid var(--border);
}
.card-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.2px;
  display: flex;
  align-items: center;
  gap: 9px;
}
.card-head h2 .step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 7px;
  background: var(--accent-grad);
  color: #fff;
  font-size: 12px;
}
.card-body { padding: 18px; }

/* ------------------------- editor / source card ----------------------- */
.editor-wrap { position: relative; }

.code-editor {
  display: block;
  width: 100%;
  min-height: 320px;
  resize: vertical;
  padding: 16px;
  border: 0;
  border-radius: 0;
  outline: none;
  color: #e2e8f0;
  background: var(--code-bg);
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.65;
  tab-size: 2;
  caret-color: #a5b4fc;
}
.code-editor::placeholder { color: #55618a; }
.code-editor:focus-visible { box-shadow: inset 0 0 0 2px rgba(129, 140, 248, 0.6); }

@media (min-width: 1020px) { .code-editor { min-height: 460px; } }

/* editor toolbar buttons */
.btn-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 700;
  font-family: var(--font);
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.14s, box-shadow 0.14s, background 0.14s, border-color 0.14s, opacity 0.14s;
  user-select: none;
}
.btn:active:not(:disabled) { transform: translateY(1px) scale(0.99); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
  color: #fff;
  background: var(--accent-grad);
  box-shadow: 0 10px 22px rgba(99, 102, 241, 0.32);
  padding: 11px 18px;
  font-size: 14px;
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.07); transform: translateY(-1px); }

.btn-secondary {
  color: var(--text-0);
  background: rgba(148, 163, 184, 0.12);
  border-color: var(--border-strong);
}
.btn-secondary:hover:not(:disabled) { background: rgba(148, 163, 184, 0.2); }

.btn-ghost {
  color: var(--text-1);
  background: transparent;
  border-color: var(--border);
}
.btn-ghost:hover:not(:disabled) { background: rgba(148, 163, 184, 0.1); color: var(--text-0); }

.btn-danger-ghost { color: var(--danger); }
.btn-danger-ghost:hover:not(:disabled) { background: rgba(251, 113, 133, 0.1); }

/* drag & drop overlay */
.drop-hint {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 700;
  color: #c7d2fe;
  background: rgba(99, 102, 241, 0.28);
  border: 2px dashed #a5b4fc;
  border-radius: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  z-index: 5;
  text-align: center;
  padding: 10px;
}
.editor-wrap.dragover .drop-hint { opacity: 1; }

/* ------------------------------ stats bar ---------------------------- */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  background: rgba(148, 163, 184, 0.05);
}
@media (min-width: 640px) { .stats-bar { grid-template-columns: repeat(4, 1fr); } }

.stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.stat b {
  font-size: 15px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat span {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  color: var(--text-2);
}
.stat-ok b { color: var(--ok); }
.stat-busy b { color: var(--warn); }

/* --------------------------- settings card --------------------------- */
.setting-group + .setting-group { margin-top: 20px; }

.group-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text-2);
}

.field { margin-bottom: 13px; }
.field label {
  display: block;
  font-size: 12.5px;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text-1);
}

.pass-row { position: relative; }
.pass-row input {
  width: 100%;
  padding: 11px 44px 11px 13px;
  font-size: 14px;
  font-family: var(--font);
  color: var(--text-0);
  background: rgba(148, 163, 184, 0.09);
  border: 1px solid var(--border-strong);
  border-radius: 11px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.pass-row input:focus {
  border-color: #818cf8;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25);
}
.eye-btn {
  position: absolute;
  right: 5px;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 0;
  border-radius: 9px;
  color: var(--text-2);
  cursor: pointer;
  font-size: 16px;
}
.eye-btn:hover { color: var(--text-0); background: rgba(148, 163, 184, 0.15); }

/* strength meter */
.meter-track {
  height: 7px;
  border-radius: 99px;
  background: rgba(148, 163, 184, 0.18);
  overflow: hidden;
  margin: 9px 0 4px;
}
.meter-fill {
  height: 100%;
  width: 0;
  border-radius: 99px;
  background: var(--danger);
  transition: width 0.25s ease, background 0.25s ease;
}
.meter-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-2);
}
.meter-labels .meter-word { color: var(--text-1); }

.req-list {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 10px;
}
.req-list li {
  font-size: 11.5px;
  color: var(--text-2);
  display: flex;
  align-items: center;
  gap: 6px;
}
.req-list li::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 1.5px solid var(--text-2);
  flex: 0 0 auto;
}
.req-list li.on { color: var(--ok); }
.req-list li.on::before { background: var(--ok); border-color: var(--ok); }

.warn-note {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  margin-top: 14px;
  padding: 11px 13px;
  font-size: 12px;
  line-height: 1.55;
  color: #fde68a;
  background: rgba(251, 191, 36, 0.09);
  border: 1px solid rgba(251, 191, 36, 0.28);
  border-radius: 11px;
}
@media (prefers-color-scheme: light) {
  .warn-note { color: #92400e; background: rgba(251, 191, 36, 0.14); }
}

/* protection-option toggle rows */
.opt-list { display: grid; gap: 8px; }

.opt {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: rgba(148, 163, 184, 0.05);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  user-select: none;
}
.opt:hover { border-color: var(--border-strong); background: rgba(148, 163, 184, 0.09); }
.opt input {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  margin: 1px 0 0;
  border: 2px solid var(--text-2);
  border-radius: 6px;
  cursor: pointer;
  display: grid;
  place-content: center;
  transition: background 0.15s, border-color 0.15s;
}
.opt input::before {
  content: "";
  width: 10px;
  height: 10px;
  transform: scale(0);
  transition: transform 0.12s;
  border-radius: 3px;
  background: #fff;
}
.opt input:checked { background: var(--accent-0); border-color: var(--accent-0); }
.opt input:checked::before { transform: scale(1); }
.opt input:disabled { opacity: 0.65; cursor: not-allowed; }
.opt input:disabled + .opt-body { opacity: 0.75; }
.opt-body { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.opt-title { font-size: 13px; font-weight: 700; color: var(--text-0); }
.opt-desc { font-size: 11.5px; color: var(--text-2); line-height: 1.4; }
.opt-badge {
  align-self: flex-start;
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: #a5b4fc;
  background: rgba(99, 102, 241, 0.16);
  border-radius: 6px;
  padding: 2px 7px;
  margin-left: auto;
}

/* filename */
.file-name {
  width: 100%;
  padding: 11px 13px;
  font-size: 13.5px;
  font-family: var(--mono);
  color: var(--text-0);
  background: rgba(148, 163, 184, 0.09);
  border: 1px solid var(--border-strong);
  border-radius: 11px;
  outline: none;
}
.file-name:focus { border-color: #818cf8; box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25); }

/* actions */
.actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 16px;
}
@media (min-width: 520px) {
  .actions { grid-template-columns: 0.8fr 1.4fr; }
}
.actions .btn { width: 100%; padding: 13px 14px; font-size: 14.5px; }
.btn-protect { grid-column: 1 / -1; padding: 15px 14px !important; font-size: 15.5px !important; }
@media (min-width: 520px) {
  .btn-protect { grid-column: auto; }
}

/* status */
.status-box {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(148, 163, 184, 0.06);
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
}
.status-dot {
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--text-2);
  transition: background 0.2s;
}
.status-box.ready .status-dot { background: var(--ok); }
.status-box.busy .status-dot { background: var(--warn); animation: pulse 1s ease-in-out infinite; }
.status-box.ok .status-dot { background: var(--ok); }
.status-box.error .status-dot { background: var(--danger); }
.status-text { font-size: 13px; font-weight: 700; color: var(--text-1); }
.status-box.ok .status-text { color: var(--ok); }
.status-box.error .status-text { color: var(--danger); }

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.82); }
}

/* success checklist */
.result-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: grid;
  gap: 7px;
}
.result-list li {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-1);
}
.result-list li::before {
  content: "✓";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 19px;
  height: 19px;
  flex: 0 0 auto;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 900;
  color: #052e1f;
  background: var(--ok);
}
.success-line {
  margin: 10px 0 0;
  font-size: 12px;
  color: var(--text-2);
  word-break: break-all;
}
#btn-redownload { margin-top: 10px; }

/* inline error */
.app-error {
  display: none;
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  color: #fecdd3;
  background: rgba(244, 63, 94, 0.12);
  border: 1px solid rgba(244, 63, 94, 0.4);
}
@media (prefers-color-scheme: light) {
  .app-error { color: #9f1239; background: rgba(244, 63, 94, 0.08); }
}

/* support banner */
.support-warn {
  display: none;
  margin: 0 18px;
  padding: 12px 16px;
  border-radius: 14px;
  font-size: 13px;
  font-weight: 600;
  color: #fde68a;
  background: rgba(251, 191, 36, 0.12);
  border: 1px solid rgba(251, 191, 36, 0.4);
  max-width: 1500px;
}
@media (min-width: 1020px) { .support-warn { margin: 0 auto; } }
@media (prefers-color-scheme: light) {
  .support-warn { color: #92400e; }
}

/* ------------------------- security note & footer -------------------- */
.bottom-zone {
  max-width: 1500px;
  margin: 0 auto;
  padding: 0 18px 24px;
  display: grid;
  gap: 14px;
}

.details-note {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  padding: 0 16px;
  overflow: hidden;
}
.details-note summary {
  cursor: pointer;
  padding: 13px 0;
  font-size: 13px;
  font-weight: 800;
  color: var(--text-1);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
.details-note summary::-webkit-details-marker { display: none; }
.details-note[open] summary { border-bottom: 1px solid var(--border); }
.details-note p {
  font-size: 12.5px;
  color: var(--text-1);
  line-height: 1.65;
  padding: 12px 2px 14px;
  margin: 0;
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 11.5px;
  color: var(--text-2);
  padding: 2px 2px 0;
}
.site-footer .privacy-line { display: flex; align-items: center; gap: 7px; }

/* ------------------------------- modal ------------------------------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(2, 6, 23, 0.72);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.modal.open { display: flex; }

.modal-card {
  width: 100%;
  max-width: 960px;
  height: min(86vh, 760px);
  display: flex;
  flex-direction: column;
  background: var(--card-solid);
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  animation: modalIn 0.22s cubic-bezier(0.2, 0.7, 0.3, 1) both;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(12px) scale(0.98); } to { opacity: 1; transform: none; } }

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
}
.modal-head h3 { margin: 0; font-size: 14.5px; font-weight: 800; }
.modal-head p { margin: 0; font-size: 12px; color: var(--text-2); }
.modal-frame-wrap { flex: 1; min-height: 0; background: #fff; }
.modal-frame-wrap iframe { width: 100%; height: 100%; border: 0; display: block; }

/* ---------------------------- responsive ----------------------------- */
@media (max-width: 639px) {
  .card-head { padding: 12px 14px; }
  .card-body { padding: 14px; }
  .btn-row { width: 100%; }
  .btn-row .btn { flex: 1 1 auto; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ------------------------- protection mode picker -------------------- */
.mode-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 9px;
}
@media (min-width: 560px) { .mode-grid { grid-template-columns: 1fr 1fr; } }

.mode-card {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 13px 14px;
  border: 1.5px solid var(--border);
  border-radius: 13px;
  background: rgba(148, 163, 184, 0.05);
  cursor: pointer;
  transition: border-color 0.16s, background 0.16s, box-shadow 0.16s;
  user-select: none;
}
.mode-card:hover { border-color: var(--border-strong); background: rgba(148, 163, 184, 0.09); }
.mode-card input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.mode-title { font-size: 13.5px; font-weight: 800; color: var(--text-0); display: flex; align-items: center; gap: 7px; }
.mode-desc { font-size: 11.5px; color: var(--text-2); line-height: 1.45; }
.mode-card:has(input:checked) {
  border-color: #818cf8;
  background: rgba(99, 102, 241, 0.12);
  box-shadow: 0 0 0 1px rgba(129, 140, 248, 0.5);
}
.mode-card:has(input:checked) .mode-title::after {
  content: "✓";
  margin-left: auto;
  color: var(--ok);
  font-size: 14px;
}
.mode-card:has(input:focus-visible) { outline: 3px solid rgba(129, 140, 248, 0.6); outline-offset: 1px; }
