/* ElchCrypt — client-side-encrypted secret + file sharing.
   Refined indigo system on a slate-ink base. Self-contained: no external
   fonts or assets (CSP: default-src 'self', no 'unsafe-inline'). Typography
   character comes from a deliberate scale, weight and letter-spacing — not a
   downloaded face. CSS-only motion; one staggered page-load reveal plus
   crafted hover / focus-visible / disabled / dragover / error states. */

:root {
  /* Surfaces */
  --bg: #eef1f6;
  --bg-tint: #e6ebf4;
  --card: #ffffff;
  --surface-sunken: #f7f9fc;
  --border: #e2e8f0;
  --border-strong: #d4dbe6;
  --input-border: #cbd5e1;

  /* Ink */
  --text: #0f172a;
  --text-muted: #475569;
  --text-faint: #64748b;
  --text-ghost: #94a3b8;

  /* Indigo accent system + a single cyan spark (matches the logo gradient) */
  --accent: #4f46e5;
  --accent-strong: #4338ca;
  --accent-press: #3730a3;
  --accent-ring: rgba(79, 70, 229, 0.32);
  --accent-soft: #eef2ff;
  --accent-soft-2: #e0e7ff;
  --accent-soft-border: #c7d2fe;
  --accent-soft-text: #3730a3;
  --spark: #0ea5e9;

  /* Status */
  --ok-bg: #ecfdf5;
  --ok-border: #a7f3d0;
  --ok-text: #065f46;
  --warn-bg: #fffbeb;
  --warn-border: #fde68a;
  --warn-text: #92400e;
  --err-bg: #fef2f2;
  --err-border: #fecaca;
  --err-text: #991b1b;
  --danger: #dc2626;

  /* Depth — layered, soft, trustworthy (not flashy) */
  --shadow-card: 0 1px 2px rgba(15, 23, 42, 0.04),
                 0 12px 32px -12px rgba(15, 23, 42, 0.18);
  --shadow-pop: 0 1px 2px rgba(15, 23, 42, 0.05),
                0 24px 60px -16px rgba(15, 23, 42, 0.40);
  --shadow-btn: 0 1px 2px rgba(79, 70, 229, 0.32),
                0 8px 18px -8px rgba(79, 70, 229, 0.55);

  /* Spacing scale (4px base) */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 22px;
  --sp-6: 28px;

  --radius-sm: 8px;
  --radius: 10px;
  --radius-lg: 14px;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial,
          "Noto Sans", sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", "Source Code Pro", Menlo,
          Consolas, monospace;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  /* Quiet atmosphere: two faint indigo/cyan washes anchored to the corners. */
  background-image:
    radial-gradient(120% 80% at 12% -10%, rgba(79, 70, 229, 0.10), transparent 60%),
    radial-gradient(120% 80% at 100% 0%, rgba(14, 165, 233, 0.08), transparent 55%);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.container {
  max-width: 880px;
  margin: 0 auto;
  padding: 40px 18px 64px;
}

.container.narrow { max-width: 560px; }

/* ---- Brand ------------------------------------------------------------- */

header.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: var(--sp-5);
}
.brand-logo {
  position: relative;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--spark));
  box-shadow: 0 4px 12px -2px rgba(79, 70, 229, 0.55),
              inset 0 1px 0 rgba(255, 255, 255, 0.35);
  flex: none;
}
/* A subtle keyhole mark inside the logo — security, without an image asset. */
.brand-logo::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background:
    radial-gradient(circle at 50% 40%, rgba(255, 255, 255, 0.92) 3.2px, transparent 3.6px),
    linear-gradient(rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0.92));
  background-size: 100% 100%, 2.6px 7px;
  background-position: center, 50% 60%;
  background-repeat: no-repeat;
}
.brand-name {
  font-weight: 700;
  font-size: 19px;
  letter-spacing: -0.02em;
}
.brand-name b { color: var(--accent); font-weight: 700; }

/* ---- Card -------------------------------------------------------------- */

.card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 26px;
  box-shadow: var(--shadow-card);
}
/* Hairline indigo->cyan accent along the card's top edge. */
.card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 22px;
  right: 22px;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--accent), var(--spark) 70%, transparent);
  opacity: 0.85;
}

/* ---- Two-pane layout --------------------------------------------------- */

.two-pane {
  display: grid;
  grid-template-columns: 1.7fr 1fr;
  gap: 26px;
}
.pane-right {
  border-left: 1px solid var(--border);
  padding-left: 26px;
}
@media (max-width: 720px) {
  .two-pane { grid-template-columns: 1fr; gap: var(--sp-5); }
  .pane-right {
    border-left: none;
    padding-left: 0;
    border-top: 1px solid var(--border);
    padding-top: var(--sp-5);
  }
}

/* ---- Fields & inputs --------------------------------------------------- */

label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 var(--sp-2);
}
.field { margin-bottom: var(--sp-4); }
.field:last-child { margin-bottom: 0; }

textarea,
input[type="text"],
input[type="password"],
select {
  width: 100%;
  border: 1px solid var(--input-border);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--card);
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
  appearance: none;
}
textarea::placeholder,
input::placeholder { color: var(--text-ghost); }

textarea {
  min-height: 154px;
  resize: vertical;
  background: var(--surface-sunken);
  line-height: 1.55;
}

select {
  cursor: pointer;
  /* Self-drawn chevron (no image asset) via two angled gradients. */
  background-image:
    linear-gradient(45deg, transparent 50%, var(--text-faint) 50%),
    linear-gradient(135deg, var(--text-faint) 50%, transparent 50%);
  background-position: calc(100% - 17px) center, calc(100% - 12px) center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 34px;
}

textarea:hover,
input[type="text"]:hover,
input[type="password"]:hover,
select:hover { border-color: var(--border-strong); }

textarea:focus,
input:focus,
select:focus { outline: none; }
textarea:focus-visible,
input:focus-visible,
select:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

/* ---- Buttons ----------------------------------------------------------- */

button {
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
  border-radius: var(--radius);
  border: 1px solid transparent;
  padding: 11px 16px;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease,
              box-shadow 0.16s ease, transform 0.06s ease;
}
button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-ring);
}
button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.primary {
  background: linear-gradient(180deg, var(--accent), var(--accent-strong));
  color: #fff;
  width: 100%;
  box-shadow: var(--shadow-btn);
}
.primary:hover:not(:disabled) {
  background: linear-gradient(180deg, var(--accent-strong), var(--accent-press));
}
.primary:active:not(:disabled) { transform: translateY(1px); }

.secondary {
  background: var(--card);
  color: var(--accent);
  border-color: var(--accent-soft-border);
  width: 100%;
}
.secondary:hover:not(:disabled) {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.secondary:active:not(:disabled) { transform: translateY(1px); }

.small-btn {
  background: var(--accent-soft);
  color: var(--accent-soft-text);
  border-color: transparent;
  padding: 7px 13px;
  font-size: 12.5px;
  border-radius: var(--radius-sm);
}
.small-btn:hover:not(:disabled) { background: var(--accent-soft-2); }
.small-btn:active:not(:disabled) { transform: translateY(1px); }

/* spacer between stacked actions (replaces an inline height style) */
.action-gap { height: var(--sp-2); }

/* ---- Drop zone --------------------------------------------------------- */

.drop-zone {
  position: relative;
  border: 1.5px dashed var(--text-ghost);
  border-radius: var(--radius);
  padding: 20px 14px;
  text-align: center;
  color: var(--text-faint);
  font-size: 13px;
  font-weight: 500;
  background: var(--surface-sunken);
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease, color 0.16s ease,
              box-shadow 0.16s ease;
}
.drop-zone:hover {
  border-color: var(--accent-soft-border);
  color: var(--text-muted);
  background: var(--accent-soft);
}
.drop-zone:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
.drop-zone.dragover {
  border-color: var(--accent);
  border-style: solid;
  background: var(--accent-soft);
  color: var(--accent-soft-text);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
.drop-zone .hint-line {
  font-size: 11.5px;
  font-weight: 400;
  margin-top: var(--sp-1);
  color: var(--text-ghost);
}

/* ---- File chips -------------------------------------------------------- */

.chips { margin-top: var(--sp-2); }
.chips:empty { margin-top: 0; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--accent-soft);
  color: var(--accent-soft-text);
  border: 1px solid var(--accent-soft-border);
  border-radius: 999px;
  padding: 5px 6px 5px 12px;
  font-size: 12px;
  font-weight: 500;
  margin: var(--sp-1) 6px 0 0;
  max-width: 100%;
  animation: chip-in 0.22s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.chip .chip-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 240px;
}
.chip button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  background: rgba(79, 70, 229, 0.12);
  border: none;
  border-radius: 999px;
  color: var(--accent-soft-text);
  padding: 0;
  font-size: 13px;
  line-height: 1;
  transition: background 0.14s ease, color 0.14s ease;
}
.chip button:hover {
  background: var(--danger);
  color: #fff;
}

/* ---- Size meter -------------------------------------------------------- */

.meter {
  height: 7px;
  border-radius: 999px;
  background: var(--bg-tint);
  margin-top: 11px;
  overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.08);
}
.meter-fill {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--spark));
  transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1), background 0.2s ease;
}
.meter-fill.over { background: linear-gradient(90deg, #ef4444, var(--danger)); }
.meter-label {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-faint);
  margin-top: var(--sp-1);
  font-variant-numeric: tabular-nums;
}

/* ---- Status / notice --------------------------------------------------- */

.status {
  margin-top: var(--sp-4);
  font-size: 13.5px;
  font-weight: 500;
  border-radius: var(--radius);
  padding: 0;
}
.status:not(:empty) {
  padding: 11px 13px;
  border: 1px solid transparent;
  animation: status-in 0.24s ease both;
}
.status.ok { background: var(--ok-bg); border-color: var(--ok-border); color: var(--ok-text); }
.status.error { background: var(--err-bg); border-color: var(--err-border); color: var(--err-text); }

.notice {
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: var(--sp-4);
}
.notice.warn {
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  color: var(--warn-text);
}

/* ---- Upload progress --------------------------------------------------- */
/* app.js toggles .active on this wrapper (not .hidden); hidden by default. */
.progress-wrap { margin-top: var(--sp-3); display: none; }
.progress-wrap.active { display: block; }

/* ---- Result ------------------------------------------------------------ */

.result {
  margin-top: var(--sp-4);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--border);
  animation: status-in 0.28s ease both;
}
.share-row { display: flex; gap: var(--sp-2); }
.share-row input {
  flex: 1;
  font-size: 13px;
  font-family: var(--mono);
  color: var(--accent-press);
  background: var(--accent-soft);
  border-color: var(--accent-soft-border);
}
.share-row button { white-space: nowrap; }

.hint {
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-faint);
  margin: var(--sp-2) 0 0;
}

/* ---- View page --------------------------------------------------------- */

.spacer-top { margin-top: var(--sp-4); }

.secret-output textarea {
  background: var(--surface-sunken);
  min-height: 124px;
}
.copy-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-top: var(--sp-2);
}
.views-info {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

.file-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 11px 13px;
  margin-top: var(--sp-2);
  font-size: 13px;
  background: var(--card);
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
  animation: chip-in 0.22s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.file-row:hover {
  border-color: var(--accent-soft-border);
  box-shadow: 0 4px 14px -8px rgba(79, 70, 229, 0.5);
}
.file-row .file-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}
.file-row .file-size {
  color: var(--text-faint);
  font-size: 12px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.attachments-actions { text-align: right; margin-top: var(--sp-3); }

/* ---- Utility ----------------------------------------------------------- */

.hidden { display: none !important; }

/* ---- Generator modal --------------------------------------------------- */

/* app.js toggles .active on this backdrop (not .hidden); hidden by default. */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(3px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--sp-4);
  z-index: 50;
}
.modal-backdrop.active {
  display: flex;
  animation: backdrop-in 0.18s ease both;
}
.modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  max-width: 430px;
  width: 100%;
  position: relative;
  box-shadow: var(--shadow-pop);
  animation: modal-in 0.26s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.modal h2 {
  margin: 0 0 var(--sp-4);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  background: none;
  border: none;
  font-size: 22px;
  line-height: 1;
  color: var(--text-faint);
  padding: 0;
  border-radius: var(--radius-sm);
  transition: background 0.14s ease, color 0.14s ease;
}
.modal-close:hover { background: var(--surface-sunken); color: var(--text); }

.modal-section { margin-bottom: var(--sp-4); }
.modal-section:last-of-type { margin-bottom: var(--sp-5); }

.length-control { display: flex; align-items: center; gap: var(--sp-3); }
.length-control input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 18px;
  background: transparent;
  cursor: pointer;
}
.length-control input[type="range"]:focus { outline: none; }
/* WebKit/Blink (incl. mobile Safari/Chrome): no ::-moz-range-progress here, so
   paint the accent fill via a JS-set gradient to match Firefox. */
.length-control input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(
    to right,
    var(--accent) 0 var(--fill-pct, 0%),
    var(--border) var(--fill-pct, 0%)
  );
}
.length-control input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  margin-top: -6px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--accent);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.25);
  cursor: pointer;
}
/* Firefox: neutral track, accent-filled portion to the left of the thumb. */
.length-control input[type="range"]::-moz-range-track {
  height: 6px;
  border-radius: 999px;
  background: var(--border);
}
.length-control input[type="range"]::-moz-range-progress {
  height: 6px;
  border-radius: 999px;
  background: var(--accent);
}
.length-control input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--accent);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.25);
  cursor: pointer;
}
.length-control input[type="range"]:focus-visible::-webkit-slider-thumb {
  box-shadow: 0 0 0 3px var(--accent-ring);
}
.length-control input[type="range"]:focus-visible::-moz-range-thumb {
  box-shadow: 0 0 0 3px var(--accent-ring);
}
.length-value {
  font-weight: 700;
  min-width: 2.5ch;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--accent-press);
}

.char-toggles { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-2); }
.char-toggle {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-weight: 500;
  font-size: 13px;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text);
  margin: 0;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-sunken);
  cursor: pointer;
  transition: border-color 0.14s ease, background 0.14s ease;
}
.char-toggle:hover { border-color: var(--accent-soft-border); }
.char-toggle input {
  width: auto;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.generated-output { display: flex; gap: var(--sp-2); }
.generated-output input {
  flex: 1;
  font-family: var(--mono);
  font-size: 13.5px;
  letter-spacing: 0.02em;
  color: var(--accent-press);
  background: var(--surface-sunken);
}
.modal-actions { display: flex; gap: var(--sp-2); }

/* ---- Motion ------------------------------------------------------------ */

/* Page-load reveal: brand, then card, gently rise into place. */
.brand { animation: rise 0.5s cubic-bezier(0.16, 1, 0.3, 1) both; }
.card {
  animation: rise 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;
  animation-delay: 0.08s;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes chip-in {
  from { opacity: 0; transform: translateY(4px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes status-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes backdrop-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-delay: 0ms !important;
    transition-duration: 0.001ms !important;
  }
}
