/* ── Theme tokens ─────────────────────────────────────────────────────── */
:root, [data-theme="dark"] {
  --bg:           #0f0f0f;
  --surface:      #161616;
  --border:       #282828;
  --border-focus: #484848;
  --text:         #e4e4e4;
  --muted:        #555;
  --placeholder:  #2d2d2d;
  --prefix-color: #383838;
  --accent:       #c8f060;
  --accent-dim:   #8ab040;
  --success:      #4dffb4;
  --danger:       #ff6060;
  --res-ok-border:#243318;
  --res-ok-bg:    #0b120a;
  --res-ok-tag:   #3d6225;
  --res-ok-meta-border: #1a2018;
  --res-ok-meta:  #303030;
  --res-ok-meta-b:#454545;
  --res-ok-tip:   #2a4a25;
  --res-err-border:#3a1c1c;
  --res-err-bg:   #110a0a;
  --res-err-tag:  #7a2e2e;
  --label-em:     #303030;
  --footer:       #222;
  --theme-btn-bg: #1c1c1c;
  --theme-btn-border: #333;
  --theme-btn-text: #666;
  --theme-btn-active-bg: #2a2a2a;
  --theme-btn-active-text: #c8f060;
}

[data-theme="light"] {
  --bg:           #f4f4f0;
  --surface:      #ffffff;
  --border:       #d8d8d0;
  --border-focus: #999990;
  --text:         #1a1a1a;
  --muted:        #888;
  --placeholder:  #ccc;
  --prefix-color: #aaa;
  --accent:       #5a8a00;
  --accent-dim:   #3d6200;
  --success:      #1a7a50;
  --danger:       #cc2222;
  --res-ok-border:#b8d8a0;
  --res-ok-bg:    #f0f8e8;
  --res-ok-tag:   #5a8a00;
  --res-ok-meta-border: #cce0b8;
  --res-ok-meta:  #888;
  --res-ok-meta-b:#555;
  --res-ok-tip:   #7aaa40;
  --res-err-border:#f0c0c0;
  --res-err-bg:   #fff5f5;
  --res-err-tag:  #cc4444;
  --label-em:     #bbb;
  --footer:       #ccc;
  --theme-btn-bg: #ebebeb;
  --theme-btn-border: #ddd;
  --theme-btn-text: #aaa;
  --theme-btn-active-bg: #fff;
  --theme-btn-active-text: #5a8a00;
}

/* ── Reset ────────────────────────────────────────────────────────────── */
* { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Base ─────────────────────────────────────────────────────────────── */
:root { font-size: 20px; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Courier New', 'Lucida Console', Menlo, monospace;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  transition: background 0.2s, color 0.2s;
}

/* ── Theme toggle ─────────────────────────────────────────────────────── */
.theme-toggle {
  position: fixed;
  top: 1rem;
  right: 1rem;
  display: flex;
  gap: 2px;
  background: var(--theme-btn-bg);
  border: 1px solid var(--theme-btn-border);
  border-radius: 4px;
  padding: 3px;
}

.theme-toggle button {
  background: transparent;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.58rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--theme-btn-text);
  padding: 4px 7px;
  transition: background 0.12s, color 0.12s;
  line-height: 1;
}

.theme-toggle button:hover {
  color: var(--text);
}

.theme-toggle button.active {
  background: var(--theme-btn-active-bg);
  color: var(--theme-btn-active-text);
}

/* ── Layout ───────────────────────────────────────────────────────────── */
.wrap { width: 100%; max-width: 540px; }

.logo {
  font-size: clamp(1.6rem, 5vw, 2.2rem);
  font-weight: bold;
  letter-spacing: -0.5px;
  line-height: 1;
}
.logo .dot { color: var(--accent); }

.tagline {
  font-size: 0.65rem;
  color: var(--muted);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-top: 0.35rem;
  margin-bottom: 2.2rem;
}

/* ── Card ─────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1.6rem 1.5rem;
  transition: background 0.2s, border-color 0.2s;
}

.field + .field { margin-top: 1rem; }

label {
  display: block;
  font-size: 0.62rem;
  color: var(--muted);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin-bottom: 0.4rem;
}
label em {
  font-style: normal;
  color: var(--label-em);
  font-size: 0.58rem;
}

input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.88rem;
  padding: 0.6rem 0.85rem;
  outline: none;
  transition: border-color 0.12s, background 0.2s;
}
input:focus { border-color: var(--border-focus); }
input::placeholder { color: var(--placeholder); }

.alias-row {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  overflow: hidden;
  transition: border-color 0.12s, background 0.2s;
}
.alias-row:focus-within { border-color: var(--border-focus); }

.alias-prefix {
  font-size: 0.75rem;
  color: var(--prefix-color);
  padding: 0.6rem 0.7rem;
  border-right: 1px solid var(--border);
  white-space: nowrap;
  user-select: none;
  display: flex;
  align-items: center;
}
.alias-row input {
  border: none;
  border-radius: 0;
  flex: 1;
}

/* ── Button ───────────────────────────────────────────────────────────── */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  width: 100%;
  margin-top: 1.2rem;
  background: var(--accent);
  color: #0a0a0a;
  border: none;
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: bold;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  padding: 0.8rem;
  cursor: pointer;
  transition: background 0.12s;
}
.btn:hover:not(:disabled) { background: var(--accent-dim); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.spinner {
  width: 13px;
  height: 13px;
  border: 2px solid rgba(0,0,0,0.2);
  border-top-color: #0a0a0a;
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
  flex-shrink: 0;
  display: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Progress ─────────────────────────────────────────────────────────── */
.progress-wrap { margin-top: 1.2rem; display: none; }
.progress-wrap.visible { display: block; }

.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}
.progress-label {
  font-size: 0.62rem;
  color: var(--muted);
  letter-spacing: 0.15em;
  text-transform: uppercase;
}
.cursor {
  color: var(--accent);
  animation: blink 0.9s step-end infinite;
  font-size: 0.9rem;
  line-height: 1;
}
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0} }

.progress-track {
  height: 2px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.4s ease;
}

/* ── Result ───────────────────────────────────────────────────────────── */
.result {
  margin-top: 1.2rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1rem 1.1rem;
  animation: pop 0.25s ease;
}
@keyframes pop {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 1; transform: translateY(0); }
}
.result.ok  { border-color: var(--res-ok-border);  background: var(--res-ok-bg); }
.result.err { border-color: var(--res-err-border); background: var(--res-err-bg); }

.result-tag {
  font-size: 0.58rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-bottom: 0.5rem;
}
.result.ok  .result-tag { color: var(--res-ok-tag); }
.result.err .result-tag { color: var(--res-err-tag); }

.copy-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.copy-btn {
  flex-shrink: 0;
  background: none;
  border: 1px solid var(--res-ok-border);
  border-radius: 4px;
  color: var(--res-ok-tip);
  cursor: pointer;
  padding: 4px 6px;
  line-height: 1;
  transition: border-color 0.12s, color 0.12s, background 0.12s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.copy-btn:hover {
  border-color: var(--success);
  color: var(--success);
  background: rgba(77,255,180,0.06);
}
.copy-btn svg {
  display: block;
  width: 15px;
  height: 15px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.short-url {
  font-size: 1.05rem;
  font-weight: bold;
  color: var(--success);
  word-break: break-all;
}

.result-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  margin-top: 0.7rem;
  padding-top: 0.7rem;
  border-top: 1px solid var(--res-ok-meta-border);
  font-size: 0.68rem;
  color: var(--res-ok-meta);
}
.result-meta b { color: var(--res-ok-meta-b); font-weight: normal; }

.err-msg { color: var(--danger); font-size: 0.9rem; }

/* ── Footer ───────────────────────────────────────────────────────────── */
.footer {
  margin-top: 1.8rem;
  font-size: 0.6rem;
  color: var(--footer);
  letter-spacing: 0.1em;
  text-align: center;
}
