@import url('https://fonts.googleapis.com/css2?family=Archivo:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;700&display=swap');

/* ===========================================================================
   Keyroom — petrol enamel and brass hardware.
   Base 16px, 1.5 rhythm, one accent (brass) spent on keys and primary actions.
   ======================================================================== */

:root {
  --bg: #0e1a1c;
  --surface: #132426;
  --surface-2: #172c2e;
  --sunk: #0b1617;
  --line: #21393b;
  --line-soft: #1b3032;
  --text: #ede8de;
  --text-dim: #93a7a4;
  --text-faint: #66807e;
  --brass: #c8a25c;
  --brass-bright: #dcb670;
  --brass-deep: #7d6331;
  --jade: #6fb49a;
  --rust: #c96a5a;

  --r-sm: 3px;
  --r-md: 6px;
  --r-lg: 10px;

  --sans: 'Archivo', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  --shell: 1120px;
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(900px 500px at 50% -10%, #16302f 0%, rgba(14, 26, 28, 0) 70%),
    var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* Fine grain keeps the flat dark field from looking like plastic. */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.05;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
}

body > * { position: relative; z-index: 1; }

a { color: var(--brass); text-underline-offset: 3px; }
a:hover { color: var(--brass-bright); }

:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 2px;
  border-radius: 2px;
}

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.02em; line-height: 1.2; }
p { margin: 0; }

/* ------------------------------------------------------------------ shell */

.shell {
  width: 100%;
  max-width: var(--shell);
  margin: 0 auto;
  padding: 0 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 76px;
  border-bottom: 1px solid var(--line-soft);
}

.mark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 17px;
  letter-spacing: -0.01em;
  color: var(--text);
  text-decoration: none;
}

.mark svg { display: block; }
.mark:hover { color: var(--text); }

.account { display: flex; align-items: center; gap: 12px; }

.account-name {
  font-size: 14px;
  color: var(--text-dim);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-dim);
  cursor: pointer;
  text-decoration: none;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.icon-btn:hover { color: var(--brass); border-color: var(--brass-deep); }

/* ----------------------------------------------------------------- hero */

.hero {
  max-width: 580px;
  margin: 0 auto;
  padding: 72px 0 96px;
  text-align: center;
}

.hero h1 { font-size: 40px; }

.hero .lede {
  margin-top: 14px;
  color: var(--text-dim);
  font-size: 17px;
}

.keyform { margin-top: 40px; }

/* The plate is the hero: an engraved slot for the code. */
.plate {
  width: 100%;
  padding: 24px 20px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: linear-gradient(180deg, var(--sunk), #101f21);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.55), 0 1px 0 rgba(255, 255, 255, 0.03);
  color: var(--text);
  font-family: var(--mono);
  font-size: 21px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-align: center;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.plate::placeholder { color: #3f5a5a; letter-spacing: 0.12em; }

.plate:focus {
  outline: none;
  border-color: var(--brass-deep);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.55), 0 0 0 3px rgba(200, 162, 92, 0.16);
}

.plate.is-wrong { border-color: var(--rust); }

.form-error {
  margin-top: 14px;
  color: var(--rust);
  font-size: 14px;
  min-height: 20px;
}

.hint { margin-top: 18px; color: var(--text-faint); font-size: 13px; }

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 20px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: var(--brass);
  color: #16211a;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.08s ease;
}

.btn:hover { background: var(--brass-bright); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-block { width: 100%; }
.btn-lg { min-height: 52px; font-size: 16px; margin-top: 16px; }

.btn-quiet {
  background: transparent;
  border-color: var(--line);
  color: var(--text);
}
.btn-quiet:hover { background: var(--surface-2); border-color: var(--brass-deep); }

.btn-danger { background: transparent; border-color: #5a2f2a; color: var(--rust); }
.btn-danger:hover { background: rgba(201, 106, 90, 0.12); }

.btn-sm { min-height: 34px; padding: 0 12px; font-size: 13px; font-weight: 500; }

/* ---------------------------------------------------------------- panels */

.panel {
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
  background: var(--surface);
  padding: 24px;
}

.result { margin-top: 34px; text-align: left; }

.result-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.result-head h2 { font-size: 20px; }

.result-notes { margin-top: 8px; color: var(--text-dim); font-size: 15px; white-space: pre-wrap; }

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line-soft);
  color: var(--text-faint);
  font-size: 13px;
}

.meta b { color: var(--text-dim); font-weight: 500; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: none;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 500;
}

.badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-faint);
}

.badge-text::before { background: var(--jade); }
.badge-url::before { background: var(--brass); }
.badge-file::before { background: #7ea6c9; }
.badge-off::before { background: var(--rust); }

.content-block {
  margin-top: 18px;
  padding: 18px;
  border: 1px solid var(--line-soft);
  border-radius: var(--r-sm);
  background: var(--sunk);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 420px;
  overflow: auto;
}

.link-out { font-family: var(--mono); font-size: 14px; word-break: break-all; }

.filecard {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 18px;
  padding: 16px 18px;
  border: 1px solid var(--line-soft);
  border-radius: var(--r-sm);
  background: var(--sunk);
}

.filecard .name { font-family: var(--mono); font-size: 14px; word-break: break-all; }
.filecard .size { color: var(--text-faint); font-size: 13px; margin-top: 2px; }

.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }

.saved-note {
  margin-top: 16px;
  color: var(--jade);
  font-size: 14px;
}

/* ------------------------------------------------------------ auth pages */

.auth {
  max-width: 400px;
  margin: 0 auto;
  padding: 80px 0 100px;
}

.auth h1 { font-size: 30px; }
.auth .lede { margin-top: 10px; color: var(--text-dim); font-size: 15px; }
.auth form { margin-top: 32px; }
.auth .alt { margin-top: 24px; color: var(--text-dim); font-size: 14px; }

.field { margin-bottom: 18px; }

.field label {
  display: block;
  margin-bottom: 7px;
  color: var(--text-dim);
  font-size: 14px;
}

.input,
.select,
.textarea {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--sunk);
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.textarea { min-height: 130px; resize: vertical; font-family: var(--mono); font-size: 14px; }

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--brass-deep);
  box-shadow: 0 0 0 3px rgba(200, 162, 92, 0.14);
}

.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%2393a7a4' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
}

.row { display: flex; gap: 12px; }
.row > * { flex: 1; min-width: 0; }

.check {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--text-dim);
  font-size: 14px;
  cursor: pointer;
}

.check input { accent-color: var(--brass); width: 16px; height: 16px; }

/* ---------------------------------------------------------------- vault */

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  padding: 56px 0 28px;
}

.page-head h1 { font-size: 30px; }
.page-head .lede { margin-top: 8px; color: var(--text-dim); font-size: 15px; }

.items { border-top: 1px solid var(--line-soft); }

.item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 18px;
  width: 100%;
  padding: 18px 12px;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s ease;
}

.item:hover { background: var(--surface-2); }
.item .title { font-weight: 500; }
.item .sub { margin-top: 4px; color: var(--text-faint); font-size: 13px; }
.item .when { color: var(--text-faint); font-size: 13px; white-space: nowrap; }

.empty {
  padding: 64px 24px;
  border: 1px dashed var(--line);
  border-radius: var(--r-md);
  text-align: center;
  color: var(--text-dim);
}

.empty h2 { font-size: 18px; margin-bottom: 8px; }

/* --------------------------------------------------------------- dialog */

.scrim {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(6, 13, 14, 0.72);
}

.dialog {
  width: 100%;
  max-width: 640px;
  max-height: 84vh;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  padding: 26px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}

.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 6px;
}

.dialog-head h2 { font-size: 20px; }

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

.toasts {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--brass);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
  max-width: 340px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.toast-bad { border-left-color: var(--rust); }
.toast-good { border-left-color: var(--jade); }

/* --------------------------------------------------------------- console */

.console {
  display: grid;
  grid-template-columns: 380px minmax(0, 1fr);
  gap: 28px;
  align-items: start;
  padding-bottom: 80px;
}

.console .maker { position: sticky; top: 24px; }

.section-title {
  margin-bottom: 16px;
  color: var(--text-dim);
  font-size: 14px;
  font-weight: 500;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  margin-bottom: 22px;
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
  background: var(--line-soft);
  overflow: hidden;
}

.stat { background: var(--surface); padding: 16px 18px; }
.stat .n { font-family: var(--mono); font-size: 22px; font-weight: 500; }
.stat .k { margin-top: 2px; color: var(--text-faint); font-size: 12px; }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; }

.tab {
  padding: 7px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--text-dim);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.tab:hover { color: var(--text); }
.tab[aria-selected='true'] { background: var(--surface-2); border-color: var(--brass-deep); color: var(--brass); }

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.toolbar .input { max-width: 240px; }

.krow {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1.1fr) auto;
  align-items: center;
  gap: 16px;
  padding: 15px 12px;
  border-bottom: 1px solid var(--line-soft);
}

.krow:hover { background: var(--surface-2); }
.krow .label { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.krow .sub { margin-top: 4px; color: var(--text-faint); font-size: 12.5px; }
.krow .code { font-family: var(--mono); font-size: 13px; color: var(--text-dim); }
.krow .ops { display: flex; gap: 6px; justify-content: flex-end; }

.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 18px; }
.pager span { color: var(--text-faint); font-size: 13px; }

.keydrop {
  margin-top: 18px;
  padding: 16px;
  border: 1px solid var(--brass-deep);
  border-radius: var(--r-sm);
  background: rgba(200, 162, 92, 0.06);
}

.keydrop h3 { font-size: 15px; margin-bottom: 10px; }

.keylist {
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.9;
  word-break: break-all;
  max-height: 200px;
  overflow: auto;
}

.preview {
  margin-top: -6px;
  margin-bottom: 18px;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text-faint);
  word-break: break-all;
}

.divider { height: 1px; background: var(--line-soft); margin: 22px 0; }

[hidden] { display: none !important; }
.center { text-align: center; }
.hint-inline { color: var(--text-faint); font-size: 12.5px; }
.field .hint { margin-top: 7px; }

.file-input { font-size: 14px; color: var(--text-dim); }
.file-input::file-selector-button {
  margin-right: 12px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

/* ------------------------------------------------------------ responsive */

@media (max-width: 960px) {
  .console { grid-template-columns: 1fr; }
  .console .maker { position: static; }
  .stats { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .shell { padding: 0 16px; }
  .hero { padding: 48px 0 64px; }
  .hero h1 { font-size: 31px; }
  .plate { font-size: 17px; letter-spacing: 0.1em; padding: 20px 14px; }
  .item { grid-template-columns: 1fr auto; }
  .item .when { display: none; }
  .krow { grid-template-columns: 1fr; gap: 10px; }
  .krow .ops { justify-content: flex-start; }
  .toasts { left: 16px; right: 16px; }
  .toast { max-width: none; }
}

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

/* One deliberate moment: the unlocked resource arriving. */
@keyframes lift {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.result[data-fresh='true'] { animation: lift 0.32s cubic-bezier(0.2, 0.7, 0.3, 1); }

/* ------------------------------------------------------------- people ---- */

.people {
  max-width: 60rem;
  margin: 0 auto;
}

.navlink {
  margin-left: auto;
  margin-right: 1rem;
  color: var(--text-dim);
  font-size: 14px;
  text-decoration: none;
  border-bottom: 1px solid var(--line);
  padding-bottom: 2px;
}

.navlink:hover {
  color: var(--text);
}

.facts {
  display: grid;
  grid-template-columns: 9rem 1fr;
  gap: 0.35rem 1rem;
  margin: 0 0 1.25rem;
  font-size: 0.9rem;
}

.facts dt {
  color: var(--muted);
}

.facts dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.person h3 {
  margin: 1.5rem 0 0.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  font-size: 0.95rem;
}

.person .inline {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.5rem;
}

.person .inline .input {
  flex: 1;
  min-width: 0;
}

/* Detail sheet ------------------------------------------------------------ */

.sheet {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  justify-content: flex-end;
}

.sheet[hidden] {
  display: none;
}

.sheet-scrim {
  position: absolute;
  inset: 0;
  background: rgba(8, 12, 14, 0.6);
}

.sheet-body {
  position: relative;
  width: min(34rem, 100%);
  overflow-y: auto;
  padding: 1.25rem 1.5rem 3rem;
  background: var(--panel, #12181b);
  border-left: 1px solid var(--line);
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.sheet-head h2 {
  margin: 0;
  overflow-wrap: anywhere;
}

@media (max-width: 40rem) {
  .facts {
    grid-template-columns: 1fr;
    gap: 0 0;
  }

  .facts dt {
    margin-top: 0.5rem;
  }

  .person .inline {
    flex-wrap: wrap;
  }
}
