:root {
  --paper: #F1F3F2;
  --white: #FFFFFF;
  --ink: #0E1B24;
  --soft: #4A5860;
  --line: #DCE3E5;
  --field: #EEF2F3;
  --sky: #58BDE7;
  --sky-pale: #CFEAF6;
  --navy: #0F3B52;
  --error: #B42318;
  --ok: #157347;
  --m: clamp(16px, 2.6vw, 40px);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-io: cubic-bezier(0.76, 0, 0.24, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; background: var(--paper); color: var(--ink); font: 400 1.0625rem/1.55 'Source Serif 4', Georgia, serif; -webkit-font-smoothing: antialiased; }
img { display: block; max-width: 100%; height: auto; }
a { color: inherit; }
h1, h2, h3, p, ol, ul, dl, dd, figure { margin: 0; }
ol, ul { padding: 0; list-style: none; }
h1, h2, h3, .sans { font-family: 'Libre Franklin', 'Helvetica Neue', Arial, sans-serif; font-weight: 700; letter-spacing: -0.03em; line-height: 1; }
:focus-visible { outline: 3px solid var(--sky); outline-offset: 3px; }
.link { text-decoration: underline; text-decoration-thickness: 0.06em; text-underline-offset: 0.2em; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 52px; padding: 0 24px; border: 0; cursor: pointer; font: 600 1rem/1 'Libre Franklin', sans-serif; text-decoration: none; background: var(--ink); color: var(--paper); transition: transform 140ms var(--ease-out), background-color 200ms ease; }
.btn:active { transform: scale(0.97); }
.btn--sky { background: var(--sky); color: var(--ink); }
.btn--ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 2px var(--ink); }
.btn--block { width: 100%; }
.btn svg { width: 18px; height: 18px; }
@media (hover: hover) and (pointer: fine) { .btn:hover { background: var(--navy); color: var(--paper); } }

/* ---------- Top bar ---------- */
.top { display: flex; align-items: stretch; min-height: 64px; background: var(--navy); color: var(--paper); }
.top__mark { display: flex; align-items: center; gap: 12px; padding: 0 20px 0 12px; background: var(--ink); text-decoration: none; font: 700 1rem/1 'Libre Franklin', sans-serif; }
.top__mark img { width: 40px; height: 40px; }
.top__mark small { color: var(--sky); font-weight: 600; margin-left: 4px; }
.top__right { margin-left: auto; display: flex; align-items: center; gap: 4px; padding-right: 8px; font: 600 0.9375rem/1 'Libre Franklin', sans-serif; }
.top__right a, .top__right button { padding: 12px 14px; color: var(--paper); background: none; border: 0; font: inherit; cursor: pointer; text-decoration: none; }
.top__right .who { color: #A9BEC8; padding: 0 12px; }
.top__right .new { background: var(--sky); color: var(--ink); }
@media (hover: hover) and (pointer: fine) { .top__right a:hover, .top__right button:hover { text-decoration: underline; } .top__right .new:hover { text-decoration: none; background: var(--paper); } }

.page { width: min(1200px, 100% - 2 * var(--m)); margin: 0 auto; padding: clamp(40px, 6vw, 80px) 0 120px; }
.page-head h1 { font-size: clamp(2.25rem, 1.4rem + 3vw, 3.75rem); }
.page-head p { margin-top: 12px; font-size: clamp(1.125rem, 1rem + 0.5vw, 1.375rem); color: var(--soft); max-width: 46ch; }

/* ---------- Status chip ---------- */
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px; font: 600 0.875rem/1 'Libre Franklin', sans-serif; background: var(--field); color: var(--ink); white-space: nowrap; }
.chip::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.chip--pending { background: #FFF3D6; color: #8A5A00; }
.chip--reviewing, .chip--in_progress { background: var(--sky-pale); color: var(--navy); }
.chip--proposal_sent { background: var(--ink); color: var(--sky); }
.chip--delivered { background: #DDF2E5; color: var(--ok); }
.chip--cancelled { background: var(--field); color: var(--soft); }

/* ---------- Request list ---------- */
.list { margin-top: 48px; display: grid; gap: 8px; }
.row { display: grid; grid-template-columns: 7rem 1fr auto auto 2rem; gap: 20px; align-items: center; padding: 24px 28px; background: var(--white); text-decoration: none; position: relative; isolation: isolate; transition: transform 300ms var(--ease-out); }
.row::before { content: ""; position: absolute; inset: 0; z-index: -1; background: var(--sky-pale); transform: scaleX(0); transform-origin: left; transition: transform 450ms var(--ease-out); }
.row__ref { font: 700 1rem/1 'Libre Franklin', sans-serif; color: var(--soft); }
.row__main b { display: block; font: 700 1.25rem/1.2 'Libre Franklin', sans-serif; letter-spacing: -0.02em; }
.row__main span { color: var(--soft); font-size: 0.9375rem; }
.row__new { font: 600 0.8125rem/1 'Libre Franklin', sans-serif; background: var(--error); color: #fff; padding: 6px 9px; border-radius: 999px; }
.row svg { width: 18px; height: 18px; transition: transform 300ms var(--ease-out); }
@media (hover: hover) and (pointer: fine) { .row:hover::before { transform: scaleX(1); } .row:hover svg { transform: translateX(4px); } }
.empty { margin-top: 48px; background: var(--white); padding: 48px; }
.empty h2 { font-size: 1.75rem; }
.empty p { margin: 12px 0 24px; color: var(--soft); max-width: 44ch; }

/* ---------- Request detail ---------- */
.back { display: inline-flex; gap: 8px; align-items: center; font: 600 0.9375rem/1 'Libre Franklin', sans-serif; text-decoration: none; color: var(--soft); margin-bottom: 24px; }
.detail-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px 32px; }
.detail-head .ref { font: 600 0.9375rem/1 'Libre Franklin', sans-serif; color: var(--soft); margin-bottom: 10px; }

.timeline { margin-top: 40px; display: grid; grid-template-columns: repeat(5, 1fr); background: var(--white); }
.timeline li { position: relative; padding: 22px 20px 20px; font: 600 0.9375rem/1.25 'Libre Franklin', sans-serif; color: var(--soft); }
.timeline li::after { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 5px; background: var(--line); }
.timeline li b { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--field); margin-bottom: 10px; font-size: 0.8125rem; color: var(--ink); }
.timeline li.done { color: var(--ink); }
.timeline li.done::after { background: var(--navy); }
.timeline li.done b { background: var(--navy); color: var(--sky); }
.timeline li.now { color: var(--ink); }
.timeline li.now::after { background: var(--sky); transform-origin: left; animation: grow 900ms var(--ease-io) 200ms both; }
.timeline li.now b { background: var(--sky); animation: pop 500ms var(--ease-out) 700ms both; }
.cancelled-note { margin-top: 24px; background: var(--white); padding: 20px 24px; color: var(--soft); }

.grid { margin-top: 12px; display: grid; grid-template-columns: 1.6fr 1fr; gap: 12px; align-items: start; }
.card { background: var(--white); padding: clamp(24px, 3vw, 40px); }
.card + .card { margin-top: 12px; }
.card h2 { font-size: clamp(1.5rem, 1.2rem + 1vw, 2rem); margin-bottom: 20px; }

.proposal { background: var(--navy); color: var(--paper); }
.proposal h2 { color: var(--sky); }
.proposal .price { font: 700 clamp(2.5rem, 1.6rem + 3vw, 4rem)/0.9 'Libre Franklin', sans-serif; letter-spacing: -0.04em; }
.proposal dl { margin-top: 20px; display: grid; gap: 12px; }
.proposal dt { font: 600 0.8125rem/1 'Libre Franklin', sans-serif; color: #A9BEC8; margin-bottom: 4px; }
.proposal dd { white-space: pre-line; }
.proposal .actions { margin-top: 28px; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.proposal .confirm { display: none; align-items: center; gap: 10px; flex-wrap: wrap; font: 600 1rem/1.3 'Libre Franklin', sans-serif; }
.proposal.is-confirming .confirm { display: flex; animation: rise 400ms var(--ease-out); }
.proposal.is-confirming .ask { display: none; }
.accepted { display: flex; align-items: center; gap: 14px; margin-top: 24px; font: 600 1.0625rem/1.3 'Libre Franklin', sans-serif; color: var(--sky); }
.accepted svg { width: 40px; height: 40px; flex: none; }
.accepted svg circle { fill: none; stroke: var(--sky); stroke-width: 3; }
.accepted svg path { fill: none; stroke: var(--sky); stroke-width: 3.5; stroke-dasharray: 30; stroke-dashoffset: 30; animation: draw 500ms var(--ease-out) 300ms forwards; }

.thread { display: grid; gap: 12px; max-height: 560px; overflow-y: auto; padding-right: 4px; }
.msg { max-width: 85%; padding: 14px 18px 12px; background: var(--field); }
.msg p { white-space: pre-line; }
.msg small { display: block; margin-top: 6px; font: 600 0.8125rem/1.2 'Libre Franklin', sans-serif; color: var(--soft); }
.msg--me { justify-self: end; background: var(--sky-pale); }
.msg--them { justify-self: start; }
.msg--them small b { color: var(--navy); }
.msg.is-new { animation: rise 500ms var(--ease-out); }
.thread-empty { color: var(--soft); }
.compose { margin-top: 20px; display: grid; gap: 10px; }
.input { width: 100%; min-height: 54px; padding: 12px 16px; border: 0; border-radius: 0; background: var(--field); box-shadow: inset 0 -2px 0 var(--line); font: 400 1.0625rem/1.4 'Source Serif 4', Georgia, serif; color: var(--ink); transition: box-shadow 250ms ease, background-color 250ms ease; }
textarea.input { min-height: 120px; resize: vertical; }
.input:focus { outline: none; background: #E6F4FB; box-shadow: inset 0 -3px 0 var(--sky); }
.err { color: var(--error); font: 600 0.875rem/1.3 'Libre Franklin', sans-serif; }

.files li { display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; align-items: center; padding: 14px 0; box-shadow: inset 0 -2px 0 var(--field); }
.files li a { font: 600 1rem/1.3 'Libre Franklin', sans-serif; text-decoration: none; word-break: break-word; }
.files li a:hover { text-decoration: underline; }
.files li span { color: var(--soft); font-size: 0.875rem; grid-column: 1; }
.files li svg { width: 20px; height: 20px; grid-row: 1 / 3; grid-column: 2; color: var(--navy); }
.drop { position: relative; display: grid; place-items: center; gap: 4px; min-height: 104px; margin-top: 16px; padding: 16px; text-align: center; background: var(--field); box-shadow: inset 0 0 0 2px var(--line); font: 600 0.9375rem/1.35 'Libre Franklin', sans-serif; transition: background-color 250ms ease, box-shadow 250ms ease; }
.drop small { color: var(--soft); }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop.has-file { background: #E6F4FB; box-shadow: inset 0 0 0 2px var(--navy); }

.facts { display: grid; gap: 14px; }
.facts dt { font: 600 0.8125rem/1 'Libre Franklin', sans-serif; color: var(--soft); margin-bottom: 4px; }
.facts dd { white-space: pre-line; }

/* ---------- Auth screens ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 0.9fr 1.1fr; }
.auth__side { background: var(--navy); color: var(--paper); padding: clamp(32px, 5vw, 72px) var(--m); display: flex; flex-direction: column; }
.auth__side a.mark { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; font: 700 1rem/1 'Libre Franklin', sans-serif; }
.auth__side a.mark img { width: 44px; height: 44px; }
.auth__side h1 { margin-top: auto; font-size: clamp(2.75rem, 1.6rem + 4vw, 5.5rem); line-height: 0.9; letter-spacing: -0.05em; }
.auth__side h1 span { color: var(--sky); }
.auth__side ul { margin-top: 32px; display: grid; gap: 12px; font: 600 1.0625rem/1.3 'Libre Franklin', sans-serif; }
.auth__side li { display: flex; gap: 12px; align-items: baseline; }
.auth__side li::before { content: ""; flex: none; width: 18px; height: 18px; transform: translateY(3px); background: var(--sky) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18'%3E%3Cpath d='m4.5 9.5 3 3 6-7' fill='none' stroke='%230E1B24' stroke-width='2' stroke-linecap='square'/%3E%3C/svg%3E") center / 18px no-repeat; }
.auth__main { display: grid; place-items: center; padding: clamp(32px, 5vw, 72px) var(--m); }
.auth__form { width: min(440px, 100%); }
.auth__form h2 { font-size: clamp(2rem, 1.5rem + 1.6vw, 2.75rem); }
.auth__form > p { margin-top: 12px; color: var(--soft); }
.auth__form form { margin-top: 32px; display: grid; gap: 20px; }
.field { display: grid; gap: 8px; }
.field label { font: 600 1rem/1.3 'Libre Franklin', sans-serif; }
.remember { display: flex; gap: 10px; align-items: center; font-size: 1rem; }
.remember input { width: 20px; height: 20px; accent-color: var(--ink); }
.auth__links { margin-top: 24px; display: grid; gap: 10px; font: 600 0.9375rem/1.3 'Libre Franklin', sans-serif; color: var(--soft); }
.notice { padding: 14px 18px; background: var(--sky-pale); font: 600 0.9375rem/1.4 'Libre Franklin', sans-serif; animation: rise 400ms var(--ease-out); }
.notice--error { background: #FBEFEE; color: var(--error); }

/* ---------- Toast ---------- */
.toast { position: fixed; left: 50%; bottom: 24px; z-index: 50; display: flex; align-items: center; gap: 12px; padding: 16px 22px; background: var(--ink); color: var(--paper); font: 600 1rem/1.2 'Libre Franklin', sans-serif; transform: translate(-50%, 160%); visibility: hidden; transition: transform 500ms var(--ease-io), visibility 0s linear 500ms; box-shadow: 0 18px 40px -16px rgba(0,0,0,.5); }
.toast i { width: 28px; height: 28px; border-radius: 50%; background: var(--sky); display: grid; place-items: center; flex: none; }
.toast svg { width: 16px; height: 16px; }
.toast svg path { fill: none; stroke: var(--ink); stroke-width: 2.2; stroke-dasharray: 20; stroke-dashoffset: 20; }
.toast.is-on { transform: translate(-50%, 0); visibility: visible; transition: transform 500ms var(--ease-io), visibility 0s; }
.toast.is-on svg path { animation: draw 400ms var(--ease-out) 250ms forwards; }

@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes pop { 0% { transform: scale(.6); } 60% { transform: scale(1.15); } 100% { transform: none; } }
@media (prefers-reduced-motion: no-preference) {
  .page > * { animation: rise 600ms var(--ease-out) both; }
  .page > *:nth-child(2) { animation-delay: 80ms; }
  .page > *:nth-child(3) { animation-delay: 160ms; }
  .page > *:nth-child(4) { animation-delay: 240ms; }
  .list .row { animation: rise 500ms var(--ease-out) both; animation-delay: calc(var(--n, 0) * 60ms + 150ms); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .accepted svg path { stroke-dashoffset: 0; }
}

@media (max-width: 900px) {
  .grid { grid-template-columns: 1fr; }
  .auth { grid-template-columns: 1fr; }
  .auth__side { min-height: 0; }
  .auth__side h1 { margin-top: 48px; }
  .timeline { grid-template-columns: 1fr; }
  .timeline li { display: flex; align-items: center; gap: 12px; padding: 14px 18px; }
  .timeline li::after { top: 0; bottom: 0; right: auto; width: 5px; height: auto; }
  .timeline li b { margin: 0; }
  .timeline li.now::after { transform-origin: top; animation-name: grow-y; }
}
@keyframes grow-y { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@media (max-width: 640px) {
  .top__mark span, .top__right .who { display: none; }
  .row { grid-template-columns: 1fr auto; gap: 8px 12px; padding: 20px; }
  .row__ref { grid-column: 1; }
  .row__main { grid-column: 1 / -1; }
  .row .chip { grid-column: 1; justify-self: start; }
  .row svg { grid-column: 2; grid-row: 1; }
  .row__new { grid-column: 2; grid-row: 3; justify-self: end; }
  .msg { max-width: 95%; }
  .toast { left: 16px; right: 16px; transform: translateY(160%); }
  .toast.is-on { transform: none; }
}

/* ---------- Auth screens, second pass ---------- */
.auth__side { position: relative; isolation: isolate; overflow: hidden; }
.auth__photo { position: absolute; inset: 0; z-index: -1; margin: 0; background: var(--navy); }
.auth__photo img { width: 100%; height: 100%; object-fit: cover; filter: grayscale(1) contrast(1.1); mix-blend-mode: multiply; opacity: .55; }
.auth__copy { margin-top: auto; }
.auth__copy h1 { margin-top: 0; }
.auth__tabs { display: grid; grid-template-columns: 1fr 1fr; margin-bottom: 36px; background: var(--field); }
.auth__tabs a { position: relative; padding: 16px 12px; text-align: center; text-decoration: none; font: 600 1rem/1 'Libre Franklin', sans-serif; color: var(--soft); transition: color 200ms ease, background-color 200ms ease; }
.auth__tabs a[aria-current="page"] { background: var(--ink); color: var(--paper); }
@media (hover: hover) and (pointer: fine) { .auth__tabs a:not([aria-current]):hover { color: var(--ink); background: var(--sky-pale); } }
.auth__row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; font: 600 0.9375rem/1.3 'Libre Franklin', sans-serif; }
.pw { position: relative; }
.pw .input { padding-right: 84px; }
.pw__toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); padding: 10px 12px; border: 0; background: none; cursor: pointer; font: 600 0.875rem/1 'Libre Franklin', sans-serif; color: var(--navy); }
.hint { color: var(--soft); font: 600 0.8125rem/1.3 'Libre Franklin', sans-serif; }
.stack { display: grid; gap: 20px; }
.account .card + .card { margin-top: 12px; }
.top__right .who { color: var(--paper); }
.top__right .who[aria-current="page"] { text-decoration: underline; text-underline-offset: 0.3em; }

@media (max-width: 900px) {
  .auth__side { padding-top: 24px; padding-bottom: 32px; }
  .auth__copy { margin-top: 40px; }
  .auth__copy h1 { font-size: clamp(2.25rem, 9vw, 3rem); }
  .auth__copy ul { display: none; }
  .auth__main { place-items: start center; padding-top: 32px; }
}
@media (max-width: 640px) {
  .top { min-height: 56px; }
  .top__mark { padding: 0 10px; }
  .top__right { gap: 0; padding-right: 0; font-size: 0.875rem; }
  .top__right a, .top__right button { padding: 10px 9px; }
  .top__right .who { display: inline-block; padding: 10px 9px; }
  .page { padding-top: 32px; }
  .card { padding: 22px 18px; }
  .detail-head .chip { order: -1; }
  .proposal .actions .btn, .proposal .confirm .btn { width: 100%; }
  .compose .btn { width: 100%; }
  .files li a { font-size: 0.9375rem; }
  .drop span { overflow-wrap: anywhere; }
  .auth__row { flex-direction: column; align-items: flex-start; }
}
.switch { margin-top: 32px; display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.switch form { margin: 0; }
@media (max-width: 640px) { .switch, .switch form, .switch .btn { width: 100%; } }
