/* whym.eu - dark only, by design.
   No light theme: the app is a vault, and a vault does not need a day mode.
   Everything here is a single flat layer of tokens plus the components that use
   them; there is no framework underneath. */

:root {
  --bg:        #0b0d10;
  --surface:   #14181d;
  --raised:    #1b2027;
  --border:    #262d36;
  --border-hi: #38424f;

  --text:      #e7ebf0;
  --muted:     #8b96a5;
  --faint:     #5d6775;

  --accent:    #5eead4;
  --accent-dim:#0f766e;
  --danger:    #f87171;
  --warn:      #fbbf24;
  --ok:        #4ade80;

  --radius:    14px;
  --radius-sm: 9px;
  --gap:       14px;
  --shadow:    0 10px 30px rgba(0,0,0,.5);

  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

svg { fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

/* ---------------------------------------------------------- screens ---- */

.screen { display: none; }
.screen.is-active { display: block; }
.screen--center.is-active {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: 24px 18px;
}

/* ---------------------------------------------------------- brand ------ */

.brand { display: flex; align-items: center; gap: 8px; }
.brand__mark {
  font-weight: 700;
  letter-spacing: -.03em;
  font-size: 19px;
  color: var(--text);
}
.brand--lg { justify-content: center; margin-bottom: 6px; }
.brand--lg .brand__mark {
  font-size: 34px;
  background: linear-gradient(180deg, var(--text), var(--muted));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ---------------------------------------------------------- panel ------ */

.panel {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: var(--shadow);
}
.panel__title { margin: 0; font-size: 17px; font-weight: 600; }
.panel__sub { margin: -6px 0 0; font-size: 13px; color: var(--muted); }

/* ---------------------------------------------------------- fields ----- */

.field { display: flex; flex-direction: column; gap: 6px; }
.field__label { font-size: 12px; color: var(--muted); }
.field__row { display: flex; gap: 6px; align-items: center; }
.field__row input { flex: 1; min-width: 0; }

input, textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 10px 12px;
  font: inherit;
  outline: none;
  transition: border-color .12s ease;
}
input:focus, textarea:focus { border-color: var(--accent-dim); }
input::placeholder, textarea::placeholder { color: var(--faint); }
textarea { resize: vertical; }
input[type="date"] { color-scheme: dark; }

.code-input {
  text-align: center;
  font-family: var(--mono);
  font-size: 26px;
  letter-spacing: .28em;
  padding: 12px;
}
.code-input--wide { font-size: 18px; letter-spacing: .12em; }

/* ---------------------------------------------------------- buttons ---- */

.btn {
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font: inherit;
  font-weight: 550;
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease, opacity .12s ease;
}
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn--primary { background: var(--accent); color: #05221e; }
.btn--primary:hover:not(:disabled) { background: #7df0dd; }
.btn--ghost { background: transparent; border-color: var(--border-hi); color: var(--text); }
.btn--ghost:hover:not(:disabled) { background: var(--raised); }
.btn--danger { background: transparent; border-color: #5b2b2b; color: var(--danger); }
.btn--danger:hover:not(:disabled) { background: #2a1616; }
.btn--sm { padding: 7px 10px; font-size: 13px; }

.iconbtn {
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--muted);
  cursor: pointer;
  padding: 8px;
  display: grid;
  place-items: center;
}
.iconbtn:hover { background: var(--raised); color: var(--text); }
.iconbtn svg { width: 20px; height: 20px; }
.iconbtn--sm { padding: 6px; }
.iconbtn--sm svg { width: 17px; height: 17px; }

.link {
  background: none;
  border: none;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.link:hover { color: var(--text); }

.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

/* ---------------------------------------------------------- messages --- */

.msg { margin: 0; font-size: 13px; color: var(--muted); }
.msg--error { color: var(--danger); }
.hint { margin: 0; text-align: center; }

/* ---------------------------------------------------------- strength --- */

.strength { display: flex; flex-direction: column; gap: 5px; }
.strength__bar {
  height: 4px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}
.strength__bar i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--danger);
  transition: width .2s ease, background .2s ease;
}
.strength__text { margin: 0; font-size: 12px; color: var(--muted); }

.checks { list-style: none; margin: 0; padding: 0; display: grid; gap: 5px; }
.checks li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--faint);
}
.checks__dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--border-hi);
  flex: none;
}
.checks li.is-ok { color: var(--muted); }
.checks li.is-ok .checks__dot { background: var(--ok); }

/* ---------------------------------------------------------- register --- */

.qr {
  align-self: center;
  border-radius: var(--radius-sm);
  background: #fff;
  padding: 8px;
}
.details { font-size: 13px; color: var(--muted); }
.details summary { cursor: pointer; }
.secret {
  display: block;
  margin-top: 8px;
  font-family: var(--mono);
  font-size: 13px;
  word-break: break-all;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}

.kit {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
}
.kit__label { margin: 0 0 6px; font-size: 11px; text-transform: uppercase;
  letter-spacing: .08em; color: var(--faint); }
.kit__key {
  display: block;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--accent);
  word-break: break-all;
  margin-bottom: 14px;
}
.kit__codes {
  margin: 0; padding-left: 20px;
  columns: 2;
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--text);
}
.confirm { display: flex; align-items: center; gap: 9px; font-size: 13px; color: var(--muted); }
.confirm input { width: auto; }

/* ---------------------------------------------------------- topbar ----- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  padding-top: max(12px, env(safe-area-inset-top));
  background: rgba(11,13,16,.86);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.search {
  flex: 1;
  max-width: 420px;
  margin-left: auto;
  padding: 8px 12px;
  border-radius: 999px;
}

/* ---------------------------------------------------------- grid ------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: var(--gap);
  padding: var(--gap) 16px 90px;
  max-width: 1200px;
  margin: 0 auto;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  cursor: pointer;
  text-align: left;
  color: inherit;
  font: inherit;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 116px;
  transition: border-color .12s ease, transform .12s ease, background .12s ease;
}
.card:hover { border-color: var(--border-hi); background: var(--raised); transform: translateY(-1px); }
.card:focus-visible { outline: 2px solid var(--accent-dim); outline-offset: 2px; }

.card__icon {
  width: 32px; height: 32px;
  border-radius: 8px;
  object-fit: contain;
  background: var(--raised);
  flex: none;
}
.card__icon--letter {
  display: grid;
  place-items: center;
  font-weight: 650;
  font-size: 15px;
  color: var(--accent);
  background: var(--raised);
}
.card__name {
  font-weight: 570;
  font-size: 14.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card__meta { margin-top: auto; display: grid; gap: 2px; }
.card__meta span { font-size: 11.5px; color: var(--faint); }
.card__meta b { font-weight: 500; color: var(--muted); }
.card__flag { font-size: 11px; color: var(--warn); }
.card__flag--dead { color: var(--danger); }

.empty { text-align: center; color: var(--faint); margin-top: 60px; }

/* ---------------------------------------------------------- menu ------- */

.menu {
  position: fixed;
  top: 58px;
  right: 14px;
  z-index: 20;
  background: var(--raised);
  border: 1px solid var(--border-hi);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: 5px;
  display: flex;
  flex-direction: column;
  min-width: 160px;
}
.menu__item {
  background: none;
  border: none;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  text-align: left;
  padding: 9px 12px;
  border-radius: 7px;
  cursor: pointer;
}
.menu__item:hover { background: var(--surface); }
.menu__item--danger { color: var(--danger); }

/* ---------------------------------------------------------- dialogs ---- */

.dialog {
  border: none;
  padding: 0;
  background: transparent;
  max-width: 100%;
  max-height: 100%;
  overflow: visible;
}
.dialog::backdrop { background: rgba(0,0,0,.66); backdrop-filter: blur(3px); }

.detail, .editor {
  width: min(440px, calc(100vw - 28px));
  max-height: min(86dvh, 760px);
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border-hi);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  color: var(--text);
}

.detail__head { display: flex; align-items: center; gap: 11px; }
.detail__icon { border-radius: 9px; object-fit: contain; background: var(--raised); flex: none; }
.detail__name { margin: 0; font-size: 17px; font-weight: 600; flex: 1;
  overflow: hidden; text-overflow: ellipsis; }
.detail__foot { display: flex; gap: 10px; }
.detail__foot .btn { flex: 1; }

.detail__fields { margin: 0; display: grid; gap: 12px; }
.rowitem { display: grid; gap: 3px; }
.rowitem__label { font-size: 11px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--faint); }
.rowitem__value {
  display: flex; align-items: center; gap: 8px;
  font-size: 14.5px; word-break: break-word;
}
.rowitem__value span { flex: 1; min-width: 0; }
.rowitem__value--mono span { font-family: var(--mono); font-size: 13.5px; }
.rowitem__value--muted span { color: var(--muted); font-size: 13px; }

.editor__icon { display: flex; align-items: center; gap: 12px; }
.editor__icon img { border-radius: 10px; object-fit: contain; background: var(--raised); flex: none; }
.editor__iconbtns { display: flex; gap: 6px; flex-wrap: wrap; }

.listdlg__body { display: grid; gap: 9px; }
.listrow {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13.5px;
}
.listrow__main { flex: 1; min-width: 0; }
.listrow__sub { font-size: 11.5px; color: var(--faint); }

/* ---------------------------------------------------------- toast ------ */

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  z-index: 50;
  background: var(--raised);
  border: 1px solid var(--border-hi);
  border-radius: 999px;
  padding: 9px 18px;
  font-size: 13.5px;
  box-shadow: var(--shadow);
  animation: rise .18s ease;
}
@keyframes rise { from { opacity: 0; transform: translate(-50%, 8px); } }

/* ---------------------------------------------------------- version ---- */

.version {
  position: fixed;
  right: 10px;
  bottom: 8px;
  z-index: 40;
  background: transparent;
  border: none;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 11px;
  cursor: pointer;
  padding: 4px 6px;
}
.version:hover { color: var(--muted); }

/* ---------------------------------------------------------- spinner ---- */

.spinner {
  width: 22px; height: 22px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin: 18px auto 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------- print ------ */

@media print {
  body { background: #fff; color: #000; }
  .screen, .topbar, .version, .toast, .dialog { display: none !important; }
  .print-kit { display: block !important; padding: 20px; font-family: var(--mono); }
}

@media (max-width: 420px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 11px; padding: 11px 12px 90px; }
  .search { font-size: 16px; }  /* stops iOS zooming the page on focus */
}

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