/* elemkay dashboard — station-log aesthetic
   palette: paper cream with hairline rules, single signal-red accent,
   oxidized brass for keys. Fraunces display, Hanken Grotesk body,
   JetBrains Mono for codes. */

:root {
  --paper:       #f4ede0;
  --paper-deep:  #ebe1d0;
  --paper-soft:  #f9f4e9;
  --ink:         #1c1612;
  --ink-soft:    #3a3128;
  --ink-mid:     #6b5f4f;
  --rule:        #c9bda9;
  --rule-soft:   #ddd2bd;
  --signal:      #a8331c;
  --signal-soft: rgba(168, 51, 28, 0.16);
  --brass:       #876f3c;

  --serif: 'Fraunces', 'Iowan Old Style', 'Palatino', serif;
  --sans:  'Hanken Grotesk', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono:  'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
}

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

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

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-feature-settings: 'kern', 'liga', 'calt', 'ss01';
  line-height: 1.55;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

/* Paper grain — fixed SVG noise layered with multiply */
.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.10;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='320' height='320' viewBox='0 0 320 320'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' seed='7' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.11 0 0 0 0 0.09 0 0 0 0 0.07 0 0 0 1 0'/></filter><rect width='320' height='320' filter='url(%23n)'/></svg>");
  mix-blend-mode: multiply;
  z-index: 0;
}

/* Layout */
.container {
  max-width: 880px;
  margin: 0 auto;
  padding: 48px 32px 96px;
  position: relative;
  z-index: 1;
}

/* Masthead */
.masthead {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 72px;
}

.wordmark {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 26px;
  letter-spacing: 0.02em;
  color: var(--ink);
  text-decoration: none;
  font-variation-settings: 'opsz' 144, 'SOFT' 40, 'WONK' 1;
  line-height: 1;
  display: flex;
  align-items: baseline;
  gap: 14px;
}

.wordmark-mark { color: var(--signal); }

.wordmark-sub {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  font-weight: 400;
  color: var(--ink-mid);
}

.meta-nav {
  font-family: var(--sans);
  font-size: 13px;
  color: var(--ink-mid);
  display: flex;
  align-items: center;
  gap: 14px;
}

.meta-nav .user {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink);
  letter-spacing: 0.04em;
}

.meta-nav .user::before {
  content: '◉';
  color: var(--signal);
  margin-right: 6px;
  font-size: 10px;
}

.meta-nav a {
  color: var(--ink-soft);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  padding-bottom: 1px;
  transition: border-color .18s ease, color .18s ease;
}

.meta-nav a:hover { border-bottom-color: var(--signal); color: var(--ink); }

.meta-nav .sep { color: var(--rule); user-select: none; }

/* Page header typography */
.overline {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--signal);
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.overline::before {
  content: '';
  width: 28px;
  height: 1px;
  background: var(--signal);
  display: inline-block;
}

.display {
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(56px, 9vw, 112px);
  line-height: 0.94;
  letter-spacing: -0.035em;
  color: var(--ink);
  font-variation-settings: 'opsz' 144, 'SOFT' 50, 'WONK' 1;
  margin-bottom: 8px;
}

.display em {
  font-style: italic;
  color: var(--signal);
  font-variation-settings: 'opsz' 144, 'SOFT' 80, 'WONK' 1;
}

.lede {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(18px, 2.2vw, 22px);
  line-height: 1.45;
  color: var(--ink-soft);
  max-width: 540px;
  margin-top: 28px;
  font-variation-settings: 'opsz' 24;
}

.hairline {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: 48px 0 36px;
  position: relative;
}

.hairline::after {
  content: '';
  position: absolute;
  top: -3px;
  left: 0;
  width: 6px;
  height: 6px;
  background: var(--signal);
  transform: rotate(45deg);
  margin-top: 0;
}

.page-narrow { max-width: 620px; }

/* Telegram (new key display) */
.telegram {
  background: var(--paper-soft);
  border: 1px solid var(--ink-soft);
  margin-bottom: 72px;
  position: relative;
  box-shadow:
    0 1px 0 var(--paper),
    0 2px 0 var(--ink-soft),
    0 12px 28px -16px rgba(28, 22, 18, 0.32);
  animation: telegramArrive 0.7s cubic-bezier(0.16, 0.84, 0.28, 1) both;
}

@keyframes telegramArrive {
  from { transform: translateY(-16px) rotate(-0.4deg); opacity: 0; }
  to   { transform: translateY(0)     rotate(0);       opacity: 1; }
}

.telegram-tape {
  background: var(--ink);
  color: var(--paper);
  padding: 9px 20px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  font-weight: 500;
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.telegram-tape::before {
  content: '◆ ◆ ◆';
  color: var(--signal);
  letter-spacing: 0.18em;
}

.telegram-body {
  padding: 32px 32px 36px;
}

.telegram-label {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--ink-mid);
  margin-bottom: 14px;
}

.telegram-key {
  display: block;
  font-family: var(--mono);
  font-size: 17px;
  font-weight: 500;
  color: var(--signal);
  word-break: break-all;
  background: var(--paper);
  border: 1px dashed var(--rule);
  padding: 18px 20px;
  user-select: all;
  cursor: copy;
  line-height: 1.5;
  letter-spacing: 0.01em;
}

.telegram-note {
  font-family: var(--serif);
  font-style: italic;
  font-size: 15px;
  color: var(--ink-soft);
  margin-top: 18px;
  line-height: 1.5;
}

.telegram-note code {
  font-family: var(--mono);
  font-style: normal;
  font-size: 13px;
  background: var(--paper-deep);
  padding: 1px 7px;
  color: var(--ink);
}

/* Ledger of API keys */
.ledger {
  margin-bottom: 36px;
}

.ledger-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: baseline;
  gap: 24px;
  padding: 18px 0;
  border-bottom: 1px solid var(--rule-soft);
  transition: background .15s ease;
}

.ledger-row:hover { background: var(--paper-soft); }
.ledger-row:hover .ledger-tail { color: var(--brass); }

.ledger-prefix {
  display: flex;
  align-items: baseline;
  gap: 12px;
  font-family: var(--mono);
}

.ledger-prefix code {
  color: var(--brass);
  font-size: 16px;
  font-weight: 500;
  letter-spacing: 0.04em;
}

.ledger-tail {
  color: var(--rule);
  letter-spacing: 0.32em;
  font-size: 12px;
  transition: color .15s ease;
}

.ledger-meta {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-mid);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  white-space: nowrap;
}

.empty {
  font-family: var(--serif);
  font-style: italic;
  color: var(--ink-mid);
  padding: 28px 0;
  font-size: 18px;
  border-bottom: 1px solid var(--rule-soft);
}

/* Buttons */
.btn {
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.03em;
  padding: 12px 24px;
  border: 1px solid currentColor;
  background: transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  transition: transform .18s ease, background-color .18s ease, color .18s ease, border-color .18s ease;
  position: relative;
}

.btn-primary {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.btn-primary:hover {
  background: var(--signal);
  border-color: var(--signal);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-ghost {
  background: transparent;
  color: var(--ink-mid);
  border-color: var(--rule);
  padding: 7px 14px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-family: var(--mono);
}

.btn-ghost:hover {
  color: var(--signal);
  border-color: var(--signal);
}

.generate { margin-top: 20px; }

/* Status block (subscription page) */
.status-block { margin: 36px 0 24px; }

.status-line {
  font-family: var(--serif);
  font-size: clamp(34px, 5vw, 52px);
  font-weight: 600;
  font-variation-settings: 'opsz' 60, 'SOFT' 50, 'WONK' 1;
  letter-spacing: -0.025em;
  color: var(--ink);
  display: flex;
  align-items: baseline;
  gap: 20px;
  margin-bottom: 18px;
  line-height: 1.05;
}

.status-line em {
  font-style: italic;
  color: var(--signal);
}

.status-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
  align-self: center;
}

.status-active {
  background: var(--signal);
  box-shadow: 0 0 0 4px var(--signal-soft);
  animation: pulse 2.2s ease-in-out infinite;
}

.status-inactive {
  background: var(--paper);
  border: 1px solid var(--ink-mid);
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 4px var(--signal-soft); }
  50%      { box-shadow: 0 0 0 9px rgba(168, 51, 28, 0.04); }
}

.status-detail {
  font-family: var(--serif);
  font-style: italic;
  font-size: 19px;
  color: var(--ink-soft);
  margin-bottom: 28px;
  max-width: 540px;
  line-height: 1.5;
}

.status-meta {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-mid);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  margin-bottom: 4px;
}

/* Page-load stagger */
.page > * {
  animation: pageIn 0.55s cubic-bezier(0.16, 0.84, 0.28, 1) both;
}
.page > *:nth-child(1) { animation-delay: 0.00s; }
.page > *:nth-child(2) { animation-delay: 0.06s; }
.page > *:nth-child(3) { animation-delay: 0.12s; }
.page > *:nth-child(4) { animation-delay: 0.18s; }
.page > *:nth-child(5) { animation-delay: 0.24s; }
.page > *:nth-child(6) { animation-delay: 0.30s; }
.page > *:nth-child(7) { animation-delay: 0.36s; }

@keyframes pageIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Auth forms */
.auth-form {
  margin-top: 40px;
  display: grid;
  gap: 22px;
  max-width: 460px;
}

.auth-field {
  display: grid;
  gap: 8px;
}

.auth-field label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-mid);
}

.auth-field input[type="text"],
.auth-field input[type="email"],
.auth-field input[type="password"] {
  font-family: var(--mono);
  font-size: 15px;
  color: var(--ink);
  background: var(--paper-soft);
  border: 1px solid var(--rule);
  padding: 14px 16px;
  letter-spacing: 0.02em;
  transition: border-color .18s ease, background-color .18s ease, box-shadow .18s ease;
  width: 100%;
  border-radius: 0;
  -webkit-appearance: none;
  appearance: none;
}

.auth-field input:focus {
  outline: none;
  border-color: var(--signal);
  background: var(--paper);
  box-shadow: inset 0 -2px 0 var(--signal);
}

.auth-field input::placeholder { color: var(--rule); }

.auth-field .errorlist {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--signal);
  list-style: none;
  margin-top: 2px;
}

.auth-field .helptext {
  font-family: var(--serif);
  font-style: italic;
  font-size: 13px;
  color: var(--ink-mid);
  line-height: 1.5;
  margin-top: 2px;
}

.auth-field-check {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: -4px;
}

.auth-field-check input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--signal);
}

.auth-field-check label {
  text-transform: none;
  letter-spacing: 0.01em;
  font-family: var(--serif);
  font-style: italic;
  font-size: 16px;
  color: var(--ink-soft);
}

.form-error {
  background: var(--paper-soft);
  border-left: 3px solid var(--signal);
  padding: 14px 18px;
  margin-bottom: 8px;
  max-width: 460px;
}

.form-error ul { list-style: none; }
.form-error li {
  font-family: var(--serif);
  font-style: italic;
  color: var(--ink);
  font-size: 16px;
  line-height: 1.45;
}

.auth-actions {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 22px;
  flex-wrap: wrap;
}

.auth-actions .inline-link {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-mid);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color .18s ease, border-color .18s ease;
  padding-bottom: 2px;
}

.auth-actions .inline-link:hover {
  color: var(--signal);
  border-bottom-color: var(--signal);
}

.auth-aux {
  margin-top: 36px;
  padding-top: 24px;
  border-top: 1px solid var(--rule-soft);
  font-family: var(--serif);
  font-style: italic;
  color: var(--ink-mid);
  font-size: 16px;
  line-height: 1.5;
  max-width: 460px;
}

.auth-aux a {
  color: var(--ink);
  border-bottom: 1px solid var(--signal);
  text-decoration: none;
}

.auth-aux a:hover { color: var(--signal); }

/* Social auth */
.auth-social {
  margin-top: 32px;
  max-width: 460px;
  display: grid;
  gap: 14px;
}

.auth-social-rule {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 6px 0 14px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-mid);
}

.auth-social-rule::before,
.auth-social-rule::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--rule);
}

.social-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 13px 22px;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  background: var(--paper-soft);
  border: 1px solid var(--ink);
  text-decoration: none;
  transition: background-color .18s ease, color .18s ease, transform .18s ease;
}

.social-btn:hover {
  background: var(--ink);
  color: var(--paper);
  transform: translateY(-1px);
}

.social-btn:active { transform: translateY(0); }

.social-glyph {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.social-btn-apple {
  /* Apple's HIG asks for black-on-white or white-on-black for the official
     button. We approximate with an inverted hover; for strict App Store
     review use the official branded button asset. */
  background: var(--ink);
  color: var(--paper);
}

.social-btn-apple:hover {
  background: var(--paper-soft);
  color: var(--ink);
}

/* Connections — devices list */
.connection-row {
  grid-template-columns: 1fr auto auto;
}

.connection-name {
  display: flex;
  align-items: baseline;
  gap: 12px;
  font-family: var(--sans);
  font-size: 16px;
  color: var(--ink);
}

.connection-name strong {
  font-weight: 600;
}

.connection-kind {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-mid);
}

.connection-id code {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--brass);
  letter-spacing: 0.06em;
}

.status-pin {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
  align-self: center;
  transform: translateY(-1px);
}

.status-pin.status-active {
  background: var(--signal);
  box-shadow: 0 0 0 3px var(--signal-soft);
}

.status-pin.status-inactive {
  background: var(--paper);
  border: 1px solid var(--ink-mid);
}

@media (max-width: 640px) {
  .connection-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }
}

/* Free-tier quota meter */
.quota {
  margin-top: 56px;
  padding-top: 28px;
  border-top: 1px solid var(--rule-soft);
  max-width: 460px;
}

.quota-label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-mid);
  margin-bottom: 8px;
}

.quota-value {
  font-family: var(--serif);
  font-size: 40px;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variation-settings: 'opsz' 60, 'SOFT' 40, 'WONK' 1;
  color: var(--ink);
  line-height: 1;
}

.quota-value span {
  color: var(--ink-mid);
  font-weight: 400;
  font-size: 28px;
}

.quota-note {
  font-family: var(--serif);
  font-style: italic;
  color: var(--ink-mid);
  font-size: 15px;
  margin-top: 10px;
}

.quota-note a {
  color: var(--ink);
  border-bottom: 1px solid var(--signal);
  text-decoration: none;
}

.quota-note a:hover { color: var(--signal); }

/* Compose / mobile */
@media (max-width: 640px) {
  .container { padding: 32px 22px 64px; }
  .masthead {
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 56px;
  }
  .display { font-size: 56px; line-height: 1; }
  .lede { font-size: 18px; }
  .ledger-row {
    grid-template-columns: 1fr;
    gap: 6px;
    padding: 18px 0;
  }
  .telegram-body { padding: 24px 22px 28px; }
  .telegram-key { font-size: 14px; padding: 14px 16px; }
  .telegram-tape { font-size: 9px; letter-spacing: 0.22em; }
  .status-line { font-size: 38px; }
}
