/* Portal: same family as the apps – ivory paper, ink, hairlines; each app card carries its own accent. */
:root {
  --bg: #f5f1e8;
  --card: #fffdf8;
  --ink: #1d1b18;
  --muted: #7b7468;
  --line: #e5ddcf;
  --accent: #1d1b18;
  --bad: #a8473a;
  --serif: 'Libre Baskerville', Baskerville, Georgia, serif;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --shadow: 0 1px 2px rgba(40, 30, 10, 0.03), 0 18px 40px -28px rgba(40, 30, 10, 0.25);
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  font-family: var(--sans);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--ink); line-height: 1.55; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { opacity: 0.45; cursor: default; }
h1, h2 { margin: 0; font-weight: 400; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.ico { width: 1.2em; height: 1.2em; vertical-align: -0.22em; flex: none; }

main { max-width: 760px; margin: 0 auto; padding: calc(36px + env(safe-area-inset-top)) 20px calc(40px + env(safe-area-inset-bottom)); }

.eyebrow { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; font-size: 0.7rem; font-weight: 600; letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted); }
.display { font-family: var(--serif); letter-spacing: -0.005em; line-height: 1.2; }
.masthead { padding: 8px 4px 26px; animation: rise 0.6s var(--ease) both; }
.masthead h1 { font-size: clamp(2rem, 7vw, 2.7rem); margin-bottom: 6px; }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }

.apps { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; margin-bottom: 18px; }
.app-card {
  position: relative; display: flex; flex-direction: column; gap: 10px; padding: 24px; border-radius: 20px;
  background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow); color: var(--ink); text-decoration: none;
  transition: border-color 0.2s, transform 0.2s var(--ease); animation: rise 0.6s var(--ease) both;
}
.app-card:nth-child(2) { animation-delay: 0.06s; }
.app-card::before { content: ''; position: absolute; left: 24px; right: 24px; top: 0; height: 2px; background: var(--app); border-radius: 0 0 2px 2px; }
.app-card:hover { border-color: var(--app); transform: translateY(-2px); }
.app-head { display: flex; gap: 14px; align-items: flex-start; }
.app-head h2 { font-size: 1.6rem; }
.app-head p { margin: 2px 0 0; }
.mono { display: grid; place-items: center; flex: none; width: 52px; height: 52px; border-radius: 14px; border: 1px solid var(--app); color: var(--app); font-family: var(--serif); font-size: 1.6rem; }
.app-level { margin: 6px 0 0; font-family: var(--serif); }
.app-level i { color: var(--app); }
.level-line { height: 2px; background: var(--line); overflow: hidden; }
.level-line > div { height: 100%; background: var(--app); }
.app-stats { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin-top: 4px; }
.app-stats div { padding: 12px 4px; text-align: center; }
.app-stats div + div { border-left: 1px solid var(--line); }
.app-stats b { display: block; font-family: var(--serif); font-weight: 400; font-size: 1.3rem; }
.app-stats span { font-size: 0.62rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.app-empty { margin: 4px 0; color: var(--muted); font-style: italic; font-family: var(--serif); }
.app-go { display: inline-flex; align-items: center; gap: 8px; margin-top: auto; padding-top: 6px; font-weight: 600; color: var(--app); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow); padding: 24px; animation: rise 0.6s var(--ease) 0.12s both; }
.account h2 { font-size: 1.6rem; margin-bottom: 4px; }
.account .eyebrow .ico { width: 1.4em; height: 1.4em; }
.field { display: flex; flex-direction: column; gap: 6px; margin: 14px 0; font-size: 0.72rem; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.field input {
  font: inherit; font-size: 1.1rem; letter-spacing: 0; text-transform: none; color: var(--ink);
  padding: 13px 16px; border: 1px solid color-mix(in srgb, var(--ink) 22%, var(--line)); border-radius: 14px; background: var(--bg); outline: 0;
}
.field input:focus { border-color: var(--ink); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ink) 10%, transparent); background: var(--card); }
.form-error { color: var(--bad); font-size: 0.9rem; margin: 4px 0 0; }
.btn {
  display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; margin-top: 10px; min-height: 52px; padding: 12px 22px;
  border: 1px solid var(--line); border-radius: 999px; background: transparent; font-weight: 600; transition: border-color 0.2s, transform 0.15s var(--ease);
}
.btn:hover:not(:disabled) { border-color: var(--ink); }
.btn:active:not(:disabled) { transform: scale(0.985); }
.btn.primary { background: var(--ink); border-color: var(--ink); color: var(--card); }
.pin-change { margin: 16px 0 4px; padding-top: 12px; border-top: 1px solid var(--line); }
.pin-change summary { cursor: pointer; font-weight: 600; }
.footer { text-align: center; color: var(--muted); font-size: 0.8rem; margin-top: 26px; }

.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: var(--card); padding: 12px 20px; border-radius: 999px; font-size: 0.9rem; box-shadow: 0 16px 40px -16px rgba(0, 0, 0, 0.45); }
.toast[hidden] { display: none; }

@media (max-width: 420px) { .app-stats { grid-template-columns: repeat(2, 1fr); } .app-stats div:nth-child(3) { border-left: 0; } .app-stats div:nth-child(n + 3) { border-top: 1px solid var(--line); } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
