@font-face {
  font-family: Manrope;
  src: url("fonts/manrope-variable.ttf") format("truetype");
  font-weight: 200 800;
  font-display: swap;
}

:root {
  --paper: #f5f8ff;
  --white: #fff;
  --ink: #162b50;
  --muted: #43536d;
  --blue: #2049dd;
  --blue-dark: #1636ac;
  --ice: #e7efff;
  --line: #cdd8ea;
  --error: #9c252d;
  --success: #176140;
  --shadow: 0 15px 40px #19397b14;
  color: var(--ink);
  background: var(--paper);
  font-family: Manrope, "Segoe UI", sans-serif;
  font-synthesis: none;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
h1, h2, h3, p { margin: 0; overflow-wrap: anywhere; }
p { line-height: 1.55; }
button, input, select, textarea { font: inherit; }
a { color: inherit; }
button, summary { cursor: pointer; }
button:disabled, fieldset:disabled :is(input, select, textarea) { opacity: .63; cursor: wait; }
:focus-visible { outline: 3px solid #1e57d7; outline-offset: 3px; }

.shell { width: min(1280px, calc(100% - 64px)); margin-inline: auto; }
.sr-only, .skip-link:not(:focus) {
  position: absolute;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  width: 1px;
  height: 1px;
  overflow: hidden;
  white-space: nowrap;
}
.skip-link:focus { position: absolute; z-index: 3; padding: 10px 16px; background: white; }

.topbar { background: white; border-bottom: 1px solid #e1e9f9; }
.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 76px;
}
.wordmark { position: relative; display: block; width: clamp(120px, 16vw, 174px); aspect-ratio: 1197 / 317; overflow: hidden; }
.wordmark img { position: absolute; top: -26.8%; left: -2.34%; width: 106.94%; height: auto; }
.topbar-actions, .form-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 14px; }
.text-link { color: var(--blue-dark); font-weight: 800; text-underline-offset: 4px; }
.topbar-actions .text-link { text-decoration: none; }
.text-link:hover { text-decoration: underline; }

.button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 9px 16px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: white;
  color: var(--ink);
  font-size: .9375rem;
  font-weight: 800;
  text-align: center;
}
.button:not(:disabled):hover { background: var(--ice); }
.button.primary { border-color: var(--blue); background: var(--blue); color: white; }
.button.primary:not(:disabled):hover { border-color: var(--blue-dark); background: var(--blue-dark); }
.button.quiet { color: var(--ink); border-color: transparent; }

.loading { padding-block: 66px; }
.loading .message { margin: 12px 0; }
.auth-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, .8fr);
  align-items: center;
  gap: clamp(32px, 7vw, 120px);
  max-width: 1030px;
  margin: clamp(34px, 11vw, 135px) auto 48px;
}
.auth-intro h1, .workspace h1, .loading h1 {
  font-weight: 800;
  font-size: clamp(2.2rem, 5vw, 4.65rem);
  line-height: 1.04;
  letter-spacing: -.068em;
}
.auth-intro p { margin-top: 20px; max-width: 33rem; color: var(--muted); font-size: 1.125rem; }
.panel { border: 1px solid #e0e8f7; border-radius: 18px; background: white; box-shadow: var(--shadow); }
.auth-panel { padding: clamp(22px, 4vw, 36px); }
.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-bottom: 24px;
  padding: 4px;
  border-radius: 10px;
  background: var(--ice);
}
.segmented button {
  min-height: 44px;
  padding: 6px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--blue-dark);
  font-size: .9375rem;
  font-weight: 800;
}
.segmented button[aria-pressed="true"] { background: white; color: var(--ink); box-shadow: 0 2px 6px #193d7b20; }
.segmented button:not(:disabled):hover { color: var(--ink); }
.auth-panel form, .assistant form { display: grid; gap: 8px; }
.auth-panel label:not(:first-child), .assistant label:not(:first-child) { margin-top: 9px; }
.auth-panel .button { margin-top: 12px; }

label { font-size: .9375rem; font-weight: 800; }
input, select, textarea {
  display: block;
  width: 100%;
  min-height: 44px;
  min-width: 0;
  padding: 8px 11px;
  border: 1px solid #aebdd6;
  border-radius: 8px;
  background: white;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 600;
}
input:read-only { background: #f3f6fc; }
textarea { resize: vertical; }
select {
  appearance: none;
  padding-right: 35px;
  background: linear-gradient(45deg, transparent 50%, #43536d 50%) right 17px center / 5px 5px no-repeat,
              linear-gradient(135deg, #43536d 50%, transparent 50%) right 12px center / 5px 5px no-repeat white;
}
small, .message { font-size: .875rem; line-height: 1.48; }
small { color: var(--muted); font-weight: 600; }
.message { color: var(--muted); font-weight: 700; }
.message:empty { margin: 0; }
.message[data-kind="error"] { color: var(--error); }
.message[data-kind="success"] { color: var(--success); }

.workspace { padding-block: clamp(28px, 5vw, 64px); }
.workspace h1 { font-size: clamp(2.1rem, 4vw, 3.45rem); }
.workspace-head, .editor-head { display: flex; justify-content: space-between; align-items: center; gap: 12px 18px; flex-wrap: wrap; }
.workspace-head { margin-bottom: 24px; }
.account { margin-top: 6px; color: var(--muted); font-size: .9375rem; font-weight: 700; }
.workspace > .message:not(:empty) { margin-bottom: 14px; }
#retry-cards { margin-bottom: 14px; }
.workspace-grid { display: grid; grid-template-columns: minmax(166px, .75fr) minmax(0, 4fr); align-items: start; gap: 20px; }
.editor-layout { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(245px, 1fr); align-items: start; gap: 20px; }
.collection, .editor-panel, .link-panel { padding: clamp(16px, 2.2vw, 24px); }
.workspace h2 { font-size: 1.25rem; font-weight: 800; letter-spacing: -.032em; }
.editor-head h2 { font-size: 1.5rem; }
.collection-empty { margin-top: 8px; font-size: .875rem; color: var(--muted); }
.cards { display: grid; gap: 7px; padding: 0; margin: 12px 0 0; list-style: none; }
.cards:empty { margin: 0; }
.card-choice {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 9px 10px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: #f6f8fd;
  color: var(--ink);
  text-align: left;
  overflow-wrap: anywhere;
}
.card-choice strong { font-size: .9375rem; }
.card-choice:hover, .card-choice[aria-current="true"] { border-color: #b6c8fb; background: var(--ice); }
.state { display: inline-flex; flex: none; align-items: center; padding: 5px 9px; border-radius: 6px; background: #edf2fb; color: var(--muted); font-size: .875rem; font-weight: 800; }
.state[data-status="published"] { background: #e4f6ed; color: var(--success); }
.card-choice .state { justify-self: start; padding: 0; background: transparent; }
.editor-head { margin-bottom: 18px; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 12px; }
.fields label { display: grid; align-content: start; gap: 5px; }
.fields .wide { grid-column: 1 / -1; }
fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
.editor-panel .form-actions { margin-top: 16px; }
.editor-panel .message:not(:empty), .link-panel .message:not(:empty) { margin-top: 10px; }

.assistant { margin-top: 18px; padding-top: 14px; border-top: 1px solid #e4e9f5; }
.assistant summary { color: var(--blue-dark); font-size: .9375rem; font-weight: 800; }
.assistant form { margin-top: 12px; }
.assistant form .form-actions { margin-top: 0; }
.suggestion { display: grid; gap: 8px; margin-top: 12px; padding: 12px; border-radius: 10px; background: var(--ice); }
.suggestion-bio { white-space: pre-wrap; }
.suggestion button { justify-self: start; }

.preview-column { position: sticky; top: 16px; min-width: 0; }
.preview-column > h2 { margin: 3px 4px 11px; }
.preview {
  --card-ink: #152b51;
  --card-bg: #fdfdff;
  --card-detail: #e7eeff;
  --card-chip: #eef4ff;
  --card-stroke: #cddbf1;
  min-height: 210px;
  padding: clamp(18px, 3vw, 30px);
  border: 1px solid var(--card-stroke);
  border-radius: 18px;
  background: var(--card-bg);
  color: var(--card-ink);
  box-shadow: 0 16px 35px #152b5123;
  text-align: center;
}
.preview[data-theme="blue"] { --card-bg: #2146cc; --card-ink: #fff; --card-detail: #152d8c; --card-chip: #17379f; --card-stroke: #17379f; }
.preview[data-theme="ink"] { --card-bg: #152b51; --card-ink: #f8fbff; --card-detail: #253f69; --card-chip: #263f66; --card-stroke: #263f66; }
.preview[data-theme="lavender"] { --card-bg: #f0e9fb; --card-ink: #34204f; --card-detail: #e0cff7; --card-chip: #e9ddf9; --card-stroke: #d7c6ec; }
.avatar { display: grid; place-items: center; width: 57px; height: 57px; margin: 0 auto 12px; border-radius: 50%; background: var(--card-detail); font-weight: 800; }
.preview h3 { font-size: clamp(1.35rem, 3vw, 1.8rem); line-height: 1.13; letter-spacing: -.04em; }
.preview-work { margin-top: 6px; font-size: .9375rem; font-weight: 700; }
.preview-bio { margin-top: 14px; white-space: pre-wrap; }
.preview-contacts { display: grid; gap: 7px; margin: 15px 0 0; text-align: left; }
.preview-contacts div { min-width: 0; padding: 8px 10px; border-radius: 8px; background: var(--card-chip); }
.preview-contacts dt { font-weight: 800; font-size: .875rem; }
.preview-contacts dd { margin: 2px 0 0; overflow-wrap: anywhere; font-size: .875rem; }
.link-panel { margin-top: 16px; }
.link-panel input { margin-top: 10px; font-size: .9rem; }
.link-hint { margin: 8px 0 10px; color: var(--muted); font-size: .875rem; }
.link-panel .text-link { font-size: .875rem; }

@media (max-width: 1050px) {
  .workspace-grid { grid-template-columns: minmax(0, 1fr); gap: 15px; }
  .cards { grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr)); }
}

@media (max-width: 720px) {
  .shell { width: calc(100% - 32px); }
  .topbar-inner { min-height: 64px; }
  .auth-layout, .editor-layout { grid-template-columns: minmax(0, 1fr); }
  .preview-column { position: static; }
  .workspace-head { margin-bottom: 16px; }
}

@media (max-width: 420px) {
  .fields { grid-template-columns: minmax(0, 1fr); }
  .topbar-actions { gap: 4px 8px; }
  .topbar-actions .button { padding-inline: 8px; }
}
