:root {
  --bg-1: #F7F8F3;
  --bg-2: #F1F3EB;
  --card: #FFFFFF;
  --ink: #151C18;
  --muted: #5B6A61;
  --line: #DDE3D6;
  --accent: #0F6B5C;
  --accent-ink: #FFFFFF;
  --accent-soft: #E3EFE9;
  --gold: #A9782C;
  --gold-soft: #F3EEE0;
  --mint: #3FB89B;
  --mint-soft: #E3EFE9;
  --coral: #C0492E;
  --coral-soft: #F9EDE7;
  --code-bg: #F7F8F3;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 11px;
  --shadow-soft: 0 1px 2px rgba(15,25,20,.04), 0 10px 26px rgba(15,25,20,.06);
  --shadow-soft-sm: 0 1px 2px rgba(15,25,20,.04), 0 4px 12px rgba(15,25,20,.05);
}

[data-theme="dark"] {
  --bg-1: #0C1512;
  --bg-2: #0F1B17;
  --card: #121E19;
  --ink: #EDEFE9;
  --muted: #8FA79B;
  --line: #1E2C26;
  --accent: #3FB89B;
  --accent-ink: #0B1613;
  --accent-soft: #16332A;
  --gold: #D8B45C;
  --gold-soft: #241F13;
  --mint: #3FD8AF;
  --mint-soft: #123028;
  --coral: #F0987F;
  --coral-soft: #2A1A17;
  --code-bg: #0E1B17;
  --shadow-soft: 0 1px 2px rgba(0,0,0,.4), 0 14px 30px rgba(0,0,0,.45);
  --shadow-soft-sm: 0 0 0 1px var(--line), 0 3px 8px rgba(0,0,0,0.2);
}

[data-theme="amoled"] {
  --bg-1: #000000;
  --bg-2: #000000;
  --card: #070B09;
  --ink: #F2F4EF;
  --muted: #7C9186;
  --line: #202020;
  --accent: #3FB89B;
  --accent-ink: #00120D;
  --accent-soft: #0F251E;
  --gold: #E0C06B;
  --gold-soft: #1B160D;
  --mint: #3FD8AF;
  --mint-soft: #0F2620;
  --coral: #F0987F;
  --coral-soft: #2A1A17;
  --code-bg: #050505;
  --shadow-soft: none;
  --shadow-soft-sm: 0 0 0 1px #1E1E1E;
}

* { box-sizing: border-box; }
::selection { background: var(--gold-soft); }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

html, body { height: 100%; }
html { scrollbar-width: none; -ms-overflow-style: none; }
html::-webkit-scrollbar { display: none; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  color: var(--ink);
  background: var(--bg-1);
  font-family: "Plus Jakarta Sans", ui-sans-serif, system-ui, sans-serif;
  transition: background 0.25s ease, color 0.25s ease;
  overflow-x: hidden;
}
body::-webkit-scrollbar { display: none; }

h1, h2, .masthead strong, .eyebrow {
  font-family: "Fraunces", serif;
}

/* ===== Header ===== */
.masthead {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px clamp(16px, 5vw, 64px);
  background: color-mix(in srgb, var(--bg-1) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.masthead__brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
}

.masthead__mark {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  color: var(--gold);
}

.masthead__mark svg {
  width: 100%;
  height: 100%;
}

.masthead__text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.masthead__text strong {
  font-size: 18.5px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.masthead__text small {
  color: var(--muted);
  font-size: 11px;
  margin-top: 1px;
}

/* ===== Layout ===== */
main#app {
  flex: 1;
  padding: 26px clamp(16px, 5vw, 64px) 48px;
  display: flex;
  justify-content: center;
  position: relative;
}

.view { width: 100%; max-width: 720px; }

.masthead__actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

/* ===== Card ===== */
.card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: 26px clamp(18px, 4vw, 30px) 26px;
  overflow: hidden;
  transition: background 0.25s ease, box-shadow 0.25s ease;
}

.card--center {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 14px;
}

/* ===== Inputs ===== */
.input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--code-bg);
  color: var(--ink);
  padding: 12px 14px;
  font-family: inherit;
  font-size: 14.5px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

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

.input--area {
  min-height: 300px;
  resize: vertical;
  font-family: "JetBrains Mono", monospace;
  font-size: 14px;
  line-height: 1.6;
  margin-top: 10px;
  margin-bottom: 18px;
}

.input--area::placeholder { color: var(--muted); opacity: .7; }

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.field { display: flex; flex-direction: column; gap: 6px; }

.field__label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
}

/* ===== Password field with show/hide eye toggle ===== */
.password-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.password-wrap .input {
  padding-right: 42px;
}

.eye-toggle {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 50%;
  transition: color .15s ease, background .15s ease;
}

.eye-toggle:hover { color: var(--accent); background: var(--accent-soft); }
.eye-toggle svg { width: 18px; height: 18px; }
.eye-toggle .eye-off { display: none; }
.eye-toggle.is-visible .eye { display: none; }
.eye-toggle.is-visible .eye-off { display: block; }

.checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
  color: var(--ink);
  background: var(--gold-soft);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 20px;
  cursor: pointer;
}

.checkbox input { width: 18px; height: 18px; accent-color: var(--gold); }

/* ===== Buttons ===== */
.btn {
  border: none;
  border-radius: 999px;
  padding: 12px 22px;
  font-family: "Fraunces", serif;
  font-weight: 600;
  font-size: 14.5px;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease, border-color .2s ease;
}

.btn--primary {
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: var(--shadow-soft-sm);
}
.btn--primary:hover { transform: translateY(-1px); box-shadow: var(--shadow-soft); }
.btn--primary:active { transform: translateY(0); }

.btn--soft {
  background: var(--accent-soft);
  color: var(--accent);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}
.btn--soft:hover { background: var(--gold-soft); color: var(--gold); }

.btn--circle {
  background: var(--card);
  color: var(--ink);
  box-shadow: none;
  border: 1px solid var(--line);
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  font-family: "Plus Jakarta Sans", sans-serif;
}
.btn--circle:hover { border-color: var(--gold); }

.btn--ghost {
  background: var(--card);
  color: var(--ink);
  box-shadow: var(--shadow-soft-sm);
}

.btn--text {
  background: transparent;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 10px 6px;
  font-family: "Plus Jakarta Sans", sans-serif;
}
.btn--text:hover { color: var(--ink); }

.btn--icon {
  background: var(--bg-1);
  border-radius: 50%;
  width: 34px;
  height: 34px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card__actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}
.card__actions--wrap { flex-wrap: wrap; justify-content: center; }

/* ===== Text bits ===== */
.eyebrow {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--gold);
}

.muted { color: var(--muted); }
.small { font-size: 12.5px; }

.note {
  background: var(--coral-soft);
  color: #B75B3E;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  margin: 4px 0 16px;
}

.error {
  color: var(--coral);
  background: var(--coral-soft);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  margin-top: 14px;
}

/* ===== Result / share card ===== */
.stub__link-row {
  display: flex;
  gap: 10px;
  width: 100%;
}
.stub__link-row .input { text-align: center; color: var(--accent); font-weight: 600; }

.qr {
  width: 168px;
  height: 168px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft-sm);
  margin: 6px 0;
  border: 1px solid var(--line);
}

/* ===== Code block ===== */
.code-block {
  margin: 4px 0 20px;
  border-radius: var(--radius-md);
  background: var(--code-bg);
  border: 1px solid var(--line);
  padding: 18px 20px;
  max-height: 65vh;
  overflow: auto;
}

.code-block code {
  font-family: "JetBrains Mono", monospace !important;
  font-size: 13.5px;
  line-height: 1.65;
  background: transparent !important;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ===== History panel ===== */
.history-panel {
  position: fixed;
  top: 74px;
  right: clamp(12px, 4vw, 48px);
  width: min(340px, calc(100vw - 24px));
  z-index: 30;
  max-height: 70vh;
  overflow-y: auto;
}

.history-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.history-panel__head h2 { font-size: 15.5px; margin: 0; font-weight: 600; }

.history-list {
  list-style: none;
  margin: 12px 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.history-list a {
  color: var(--ink);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 600;
}
.history-list a:hover { color: var(--accent); }

.history-list time {
  display: block;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 400;
}

.history-list button {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
}
.history-list button:hover { color: var(--coral); }

/* ===== Footer ===== */
.foot {
  text-align: center;
  color: var(--muted);
  font-size: 11px;
  padding: 18px;
  opacity: .75;
}

/* ===== Loading awal (sebelum JS routing selesai) ===== */
.initial-loading {
  display: flex;
  justify-content: center;
  padding: 60px 0;
}

.initial-loading[hidden] {
  display: none;
}

.spinner {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
}

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

/* ===== Toast notifikasi ===== */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 16px);
  background: var(--ink);
  color: var(--bg-1);
  padding: 12px 20px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: var(--shadow-soft);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 50;
}

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

@media (max-width: 520px) {
  .card__actions { justify-content: center; }
  .stub__link-row { flex-direction: column; }
}
