/* Two palettes, one switch. settings.THEME picks the default; every colour
   below resolves through these tokens, so nothing else needs to know which
   one is live. */

:root[data-theme="oxblood"] {
  color-scheme: light;
  --ground: #E7E8E6;
  --selected: #D5D0D1;
  --accent: #5E1524;
  --ink: #1B1517;
  --ink2: #5C5558;
  --rule: #C2BCBD;
  --rule-soft: #D6D2D3;
  --field: #FCFCFB;
  --bad: #A81E10;
  --good: #1D7A3A;
  --on-accent: #FFFFFF;
  --on-bad: #FFFFFF;
}

:root, :root[data-theme="amber"] {
  color-scheme: dark;
  --ground: #161E28;
  --selected: #283545;
  --accent: #F0B429;
  --ink: #EEF3F8;
  --ink2: #93A6B8;
  --rule: #33414F;
  --rule-soft: #2A3542;
  --field: #1E2A38;
  --bad: #FF7A6B;
  --good: #4ADE80;
  --on-accent: #161E28;
  --on-bad: #2A0B05;
}

:root {
  --body: "Schibsted Grotesk", system-ui, -apple-system, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  --wrap: 1160px;
  --gap: 24px;
  --indent: 22px;
}

* { box-sizing: border-box; }

/* An author-level display: flex beats the UA stylesheet's rule for [hidden],
   so anything toggled by that attribute stays on screen without this. */
[hidden] { display: none !important; }

body {
  margin: 0; min-height: 100svh; display: flex; flex-direction: column;
  background: var(--ground); color: var(--ink);
  font-family: var(--body); font-size: 15px; line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2 { margin: 0; font-weight: 700; letter-spacing: -.022em; line-height: 1.2; }
p { margin: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* The signature of the Swiss board: one solid rule across the very top. */
.stripe { height: 10px; background: var(--accent); flex: none; }

.sr {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}

.eyebrow, .cols, .detail h2 {
  font-size: .68rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .13em; color: var(--ink2);
}

/* brand */

.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -.03em; }
.brand .mark { width: 24px; height: 24px; flex: none; }
.brand .lever { stroke: var(--accent); stroke-width: 2.2; stroke-linecap: round; fill: none; }
.brand .fulcrum { fill: var(--accent); }

/* buttons */

.btn {
  padding: 10px 15px; border: 0; border-radius: 2px;
  background: var(--accent); color: var(--on-accent);
  font: inherit; font-weight: 600; cursor: pointer;
}
.btn:hover { filter: brightness(1.12); }
.btn-ghost {
  background: none; border: 1px solid var(--rule); color: var(--ink2); font-weight: 500;
}
.btn-ghost:hover { color: var(--ink); border-color: var(--ink2); filter: none; }
.btn-sm { padding: 6px 11px; font-size: .82rem; }
/* Where Connect was, once the extension says it's connected: not a button. */
.btn-connected { display: inline-block; background: none; border: 1px solid var(--good); color: var(--good); cursor: default; }
.btn-connected.btn-sm { padding: 5px 10px; }
.btn-connected:hover { filter: none; }
.btn-danger { background: var(--bad); color: var(--on-bad); }

/* login */

.stage { flex: 1; display: grid; place-items: center; padding: 64px 16px 28px; }
.panel {
  width: 100%; max-width: 372px; padding: 34px 30px 28px;
  border: 1px solid var(--rule); background: var(--field);
}
.panel .brand { justify-content: center; font-size: 1.5rem; margin-bottom: 28px; }
.signin { display: grid; gap: 14px; }
.signin label { display: grid; gap: 5px; }
.signin label span { font-size: .78rem; font-weight: 600; color: var(--ink2); }
.signin input {
  width: 100%; padding: 11px 12px; border: 1px solid var(--rule); border-radius: 2px;
  background: var(--ground); color: var(--ink); font: inherit; font-size: .95rem;
}
.signin input::placeholder { color: var(--ink2); }
.signin .btn { margin-top: 4px; }
.note { margin: 0; min-height: 1.3em; font-size: .8rem; color: var(--ink2); text-align: center; }
.note.bad { color: var(--bad); font-weight: 600; }
.note.rules { text-align: left; padding-left: 18px; display: grid; gap: 4px; }
.foot { padding: 0 16px 24px; font-size: .76rem; color: var(--ink2); text-align: center; }

/* chrome */

.theme-toggle {
  position: fixed; top: 22px; right: 18px; width: 32px; height: 32px; z-index: 5;
  border: 1px solid var(--rule); border-radius: 2px; display: grid; place-items: center;
  background: var(--ground); color: var(--ink2); cursor: pointer;
}
.theme-toggle svg { width: 15px; height: 15px; }
.theme-toggle circle { fill: none; stroke: currentColor; stroke-width: 1.6; }
.theme-toggle path { fill: currentColor; }
.theme-toggle:hover { color: var(--ink); }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  width: 100%; max-width: var(--wrap); margin: 0 auto;
  padding: 20px var(--gap) 18px; border-bottom: 2px solid var(--ink);
}
.topbar .brand { font-size: 1.05rem; }
.topbar-right { display: flex; align-items: center; gap: 12px; font-size: .82rem; color: var(--ink2); }

.wrap { flex: 1; width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 26px var(--gap) 72px; }

/* The toggle is position:fixed at the viewport's right edge. Above 1260px the
   centred topbar ends clear of it; below that they collide, so reserve its lane. */
@media (max-width: 1259px) {
  .topbar { padding-right: 68px; }
}

/* head + toolbar */

.head { margin-bottom: 22px; }
.head-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.head h1 { font-size: 2rem; letter-spacing: -.03em; }
.head p { margin-top: 3px; color: var(--ink2); font-size: .86rem; }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.toolbar input, .toolbar select {
  padding: 9px 11px; border: 1px solid var(--rule); border-radius: 2px;
  background: var(--field); color: var(--ink); font: inherit; font-size: .86rem;
}
.toolbar input { flex: 1; min-width: 200px; }
.toolbar input::placeholder { color: var(--ink2); }

/* the table */

.cols, .row-head {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(0, 2fr) minmax(0, 1.2fr) 112px 18px;
  gap: 20px; align-items: center;
}

.cols { padding: 0 14px 9px var(--indent); border-bottom: 2px solid var(--ink); }
.cols button, .cols span {
  background: none; border: 0; padding: 0; text-align: left;
  font: inherit; font-size: .68rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .13em; color: var(--ink2);
}
.cols button { cursor: pointer; }
.cols button:hover { color: var(--ink); }
.cols button[data-dir]::after { content: " \2191"; color: var(--accent); }
.cols button[data-dir="desc"]::after { content: " \2193"; }

.rows { display: flex; flex-direction: column; }

.app { position: relative; border-bottom: 1px solid var(--rule); }
.app.hidden { display: none; }
.app[open] { background: var(--selected); }
.app[open]::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0;
  width: 4px; background: var(--accent);
}

.row-head {
  width: 100%; padding: 17px 14px 17px var(--indent);
  background: none; border: 0; cursor: pointer; font: inherit; color: inherit;
  text-align: left; list-style: none;
}
.row-head::-webkit-details-marker { display: none; }
.app:not([open]) > .row-head:hover { background: color-mix(in srgb, var(--selected) 55%, var(--ground)); }

.company { font-size: 1.62rem; font-weight: 700; letter-spacing: -.022em; line-height: 1.05; }
.title { font-size: .95rem; line-height: 1.4; }
.loc { font-size: .84rem; color: var(--ink2); }
.loc .dash { display: inline-block; width: 18px; height: 2px; background: var(--ink2); opacity: .55; vertical-align: middle; }
.date { font-size: .88rem; color: var(--ink2); font-variant-numeric: tabular-nums; }
/* A capture that could not read a value off the page, and a capture that has
   not been submitted yet. Both are states the envelope models explicitly. */
.unknown { color: var(--ink2); font-weight: 400; font-style: italic; font-size: .9rem; }
.company .unknown { font-size: 1.05rem; }
.tag {
  display: inline-block; padding: 2px 7px; border: 1px solid var(--accent);
  color: var(--accent); font-size: .68rem; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase;
}

.caret { color: var(--ink2); justify-self: end; transition: transform .18s; }
.app[open] .caret { transform: rotate(90deg); }

/* the expanded record */

.detail { padding: 2px 14px 30px var(--indent); }
.detail h2 { margin: 26px 0 8px; }
.detail h2:first-child { margin-top: 0; }

/* Fields flow into as many columns as the space allows; a long value claims a
   whole row for itself rather than being squeezed into one cell. */
.fields {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(248px, 100%), 1fr));
  gap: 18px 22px;
  align-items: start;
}
.fields .field { padding: 0 0 7px; border-bottom: 1px solid var(--rule-soft); }
.field.wide { grid-column: 1 / -1; }
.field .label { font-size: .72rem; color: var(--ink2); margin-bottom: 6px; padding-left: 7px; }

/* An application's own sections ("My Experience", "Work Experience 1"),
   nested as its page had them; one whose answers were all removed goes. */
.answers > * + *, .answer-section > * + * { margin-top: 18px; }
.answer-section > :first-child {
  margin: 0; padding-left: 7px; font-size: .82rem; font-weight: 700; letter-spacing: -.01em;
}
.answer-section .answer-section { padding-left: 14px; border-left: 2px solid var(--rule-soft); }
.answer-section:not(:has(.field-row)) { display: none; }

.files { display: flex; flex-wrap: wrap; gap: 22px; padding-top: 4px; }
.file {
  color: var(--ink); text-decoration: none; font-size: .9rem;
  border-bottom: 2px solid var(--accent); padding-bottom: 2px;
}
.file:hover { color: var(--accent); }
.attached .files { gap: 14px; padding: 0 7px 4px; }
.file.pending { color: var(--ink2); border-bottom-color: var(--rule); }
.library-note { margin: 0 0 14px; }
.edit-error { margin: 10px 0 0; }

.empty {
  border-bottom: 1px solid var(--rule); padding: 56px 20px;
  text-align: center; color: var(--ink2); font-size: .9rem;
}

/* API tokens */

.reveal { border-left: 4px solid var(--accent); background: var(--selected); padding: 15px 18px; margin-bottom: 18px; }
.reveal p:last-child { font-size: .8rem; color: var(--ink2); }


/* inline editing */

.inline-edit input,
.inline-edit textarea {
  width: 100%; font: inherit; font-size: .9rem; color: var(--ink);
  background: transparent; border: 1px solid transparent; border-radius: 2px;
  padding: 5px 7px;
}
.field.wide textarea, .field.wide input { max-width: 78ch; }
.inline-edit textarea { resize: none; overflow: hidden; line-height: 1.55; }
.inline-edit input::placeholder, .inline-edit textarea::placeholder { color: var(--ink2); }
.inline-edit input:hover, .inline-edit textarea:hover { border-color: var(--rule); }
.inline-edit input:focus, .inline-edit textarea:focus {
  outline: none; background: var(--field); border-color: var(--ink2);
}
.inline-edit .label-input { font-size: .72rem; color: var(--ink2); }
.inline-edit input[type="date"] { max-width: 20ch; }

/* Label and remove share the top line, so the control sits beside the field it
   removes instead of at the far edge of the record. */
.field-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto;
  column-gap: 6px; row-gap: 7px; align-items: center;
}
.field-row .label-input { grid-column: 1; grid-row: 1; }
.field-row textarea { grid-column: 1 / -1; grid-row: 2; }
.field-row .remove-field {
  grid-column: 2; grid-row: 1; justify-self: end;
  background: none; border: 0; color: var(--bad); cursor: pointer;
  font-size: 1.05rem; font-weight: 700; line-height: 1;
  padding: 4px 6px; border-radius: 2px;
  opacity: 0; transition: opacity .12s;
}
.field-row:hover .remove-field,
.field-row:focus-within .remove-field { opacity: 1; }
.field-row .remove-field:hover { filter: brightness(1.15); }
.field-row .remove-field:focus-visible { opacity: 1; }

/* A full-width cell would otherwise strand the remove control a thousand
   pixels from the text it belongs to, so its label gets its own narrow track
   and the rest of the row is absorbed by a trailing spacer. */
.field-row.wide { grid-template-columns: minmax(0, 34ch) auto minmax(0, 1fr); }
.field-row.wide textarea { grid-column: 1 / -1; }

/* Where the browser can size an input to its own text, the label track shrinks
   to the question and the control lands right against it. */
@supports (field-sizing: content) {
  .field-row.wide { grid-template-columns: auto auto minmax(0, 1fr); }
  .field-row.wide .label-input {
    field-sizing: content; width: auto; min-width: 10ch; max-width: 46ch;
  }
}

/* Removing a field asks first, in the same two-step shape as deleting a whole
   record -- just sized to sit inside one cell. */
.remove-confirm {
  grid-column: 1 / -1; grid-row: 3;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 7px; padding-top: 7px; border-top: 1px solid var(--rule-soft);
}
.remove-confirm .q { font-size: .76rem; font-weight: 600; color: var(--bad); }
.remove-confirm button {
  background: none; border: 0; padding: 2px 3px; cursor: pointer;
  font: inherit; font-size: .78rem; text-decoration: underline; text-underline-offset: 3px;
}
.remove-yes { color: var(--bad); font-weight: 700; }
.remove-yes:hover { filter: brightness(1.15); text-decoration-thickness: 2px; }
.remove-no { color: var(--ink2); }
.remove-no:hover { color: var(--ink); }
.field-row.pending textarea { opacity: .45; }

.add-row { display: flex; justify-content: center; margin: 20px 0 4px; }
.save-bar {
  display: flex; justify-content: center; gap: 8px;
  margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--rule);
}

/* delete */

.delete-form {
  display: flex; justify-content: center; align-items: center; gap: 10px;
  flex-wrap: wrap; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--rule);
}
/* Underlined, not just red: in the amber palette no legible red is far enough
   from the amber accent in lightness, so colour cannot be the only signal. */
.delete-link {
  background: none; border: 0; padding: 4px 8px; cursor: pointer;
  font: inherit; font-size: .85rem; font-weight: 600; color: var(--bad);
  text-decoration: underline; text-underline-offset: 3px;
}
.delete-link:hover { filter: brightness(1.1); text-decoration-thickness: 2px; }
.delete-confirm { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: center; }
.delete-confirm .note { min-height: 0; }

@media (max-width: 860px) {
  .cols { display: none; }
  .row-head { grid-template-columns: minmax(0, 1fr) 18px; gap: 2px; padding-right: 10px; }
  .row-head > .caret { grid-row: 1 / span 4; }
  .company { font-size: 1.35rem; }
}
