/* ============================================================================
   Kairos — design system
   Concept: "the opportune moment." Neutral, editorial chrome so user role
   colors carry the palette. Signature: monospaced time-rail (see planner batch).
   ========================================================================== */

:root {
    /* palette — cool paper + deep ink + a single restrained brass accent */
    --ink:        #16202e;   /* near-black indigo, primary text */
    --ink-soft:   #47566a;   /* secondary text */
    --line:       #dde3ea;   /* hairlines */
    --paper:      #f7f8fa;   /* app background */
    --surface:    #ffffff;   /* cards, panels */
    --brass:      #7a2a82;   /* brand purple */
    --brass-ink:  #6a2472;   /* brand purple text */
    --danger:     #b4432f;
    --ok:         #2f7d55;

    --radius:     10px;
    --radius-sm:  6px;
    --shadow:     0 1px 2px rgba(22,32,46,.06), 0 8px 24px rgba(22,32,46,.06);

    --font-display: "Newsreader", Georgia, serif;
    --font-body:    "Inter", system-ui, sans-serif;
    --font-mono:    "IBM Plex Mono", ui-monospace, monospace;

    --step-lg: clamp(1.9rem, 1.3rem + 2vw, 2.8rem);
    --step-md: 1.35rem;
    --step-sm: .875rem;
    --gap: 1rem;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
    font-family: var(--font-body);
    color: var(--ink);
    background: var(--paper);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--brass-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
.boot { padding: 4rem; color: var(--ink-soft); }

/* ---- typography ---------------------------------------------------------- */
h1, h2, h3 { font-family: var(--font-display); font-weight: 500; line-height: 1.15; margin: 0; letter-spacing: -.01em; }
h1 { font-size: var(--step-lg); }
h2 { font-size: var(--step-md); }
.eyebrow { font-family: var(--font-mono); font-size: .72rem; letter-spacing: .14em; text-transform: uppercase; color: var(--brass-ink); }
.muted { color: var(--ink-soft); }

/* ---- buttons ------------------------------------------------------------- */
.btn {
    font: 500 var(--step-sm)/1 var(--font-body);
    padding: .7rem 1.1rem; border-radius: var(--radius-sm);
    border: 1px solid transparent; cursor: pointer; background: var(--ink); color: #fff;
    transition: transform .04s ease, background .15s ease, border-color .15s ease;
}
.btn:hover { background: #0e1723; }
.btn:active { transform: translateY(1px); }
.btn--ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn--ghost:hover { background: #eef1f5; }
.btn--brass { background: var(--brass); }
.btn--brass:hover { background: #5f2168; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn--block { width: 100%; }

/* ---- forms --------------------------------------------------------------- */
.field { display: grid; gap: .35rem; margin-bottom: 1rem; }
.field label { font-size: .8rem; font-weight: 500; color: var(--ink-soft); }
.field input, .field select, .field textarea {
    font: 400 1rem/1.4 var(--font-body);
    padding: .65rem .8rem; border: 1px solid var(--line); border-radius: var(--radius-sm);
    background: var(--surface); color: var(--ink);
}
.field input:focus, .field select:focus, .field textarea:focus {
    outline: 2px solid var(--brass); outline-offset: 1px; border-color: transparent;
}

/* ---- feedback ------------------------------------------------------------ */
.notice { padding: .7rem .9rem; border-radius: var(--radius-sm); font-size: .875rem; margin-bottom: 1rem; }
.notice--error { background: #fbeae6; color: var(--danger); }
.notice--ok    { background: #e7f2ec; color: var(--ok); }

/* ---- auth screens -------------------------------------------------------- */
.auth {
    min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr;
}
.auth__aside {
    background: var(--ink); color: #fff; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between;
}
.auth__brand { background:#fff; padding:.6rem .9rem; border-radius:8px; display:inline-block; }
.auth__pitch h1 { color: #fff; max-width: 12ch; }
.auth__pitch p  { color: #b9c2ce; max-width: 40ch; margin-top: 1rem; }
.auth__foot { font-family: var(--font-mono); font-size: .72rem; color: #8b97a6; letter-spacing: .05em; }

.auth__main { display: grid; place-items: center; padding: 2rem; }
.auth__card { width: min(400px, 100%); }
.auth__card h2 { margin-bottom: .35rem; }
.auth__switch { margin-top: 1.25rem; font-size: .875rem; color: var(--ink-soft); }

@media (max-width: 820px) {
    .auth { grid-template-columns: 1fr; }
    .auth__aside { padding: 2rem; }
    .auth__pitch { display: none; }
}

/* ---- app shell (used from planner batch onward) -------------------------- */
.shell { min-height: 100vh; display: grid; grid-template-rows: auto 1fr; }
.topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: .8rem 1.25rem; background: var(--surface); border-bottom: 1px solid var(--line);
}
.topbar__brand { font-family: var(--font-display); font-size: 1.15rem; }
.topbar__nav { display: flex; gap: .25rem; }
.topbar__nav a { padding: .45rem .7rem; border-radius: var(--radius-sm); color: var(--ink-soft); font-size: .875rem; }
.topbar__nav a.is-active { background: #eef1f5; color: var(--ink); }
.main { padding: 1.5rem; max-width: 1200px; width: 100%; margin: 0 auto; }

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}

/* ============================================================================
   Planner — week view + schedule grid
   Signature: a monospaced time-rail down the left of the schedule.
   ========================================================================== */
.planner { display: grid; grid-template-columns: 320px 1fr; gap: 1.25rem; align-items: start; }
.planner__head { grid-column: 1 / -1; display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.weeknav { display: flex; align-items: center; gap: .5rem; }
.weeknav__label { font-family: var(--font-mono); font-size: .8rem; color: var(--ink-soft); }

/* roles + goals column */
.roles { display: grid; gap: .75rem; }
.role-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.role-card__bar { padding: .5rem .75rem; font-weight: 600; font-size: .9rem; display: flex; justify-content: space-between; align-items: center; }
.role-card__goals { list-style: none; margin: 0; padding: .4rem; display: grid; gap: .3rem; }
.goal {
    display: flex; align-items: center; gap: .4rem; padding: .4rem .55rem;
    border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--paper);
    font-size: .85rem; cursor: grab;
}
.goal:active { cursor: grabbing; }
.goal[draggable="true"]:hover { border-color: var(--brass); }
.goal__text { flex: 1; }
.goal__x { border: 0; background: none; color: var(--ink-soft); cursor: pointer; font-size: 1rem; line-height: 1; }
.goal-add { display: flex; gap: .3rem; padding: .4rem; }
.goal-add input { flex: 1; font: 400 .85rem var(--font-body); padding: .4rem .5rem; border: 1px solid var(--line); border-radius: var(--radius-sm); }

/* schedule grid */
.schedule { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: auto; }
.grid { display: grid; min-width: 720px; }
.grid__corner, .grid__day { position: sticky; top: 0; z-index: 2; background: var(--surface); border-bottom: 1px solid var(--line); padding: .5rem; font-size: .78rem; font-weight: 600; text-align: center; }
.grid__time {
    font-family: var(--font-mono); font-size: .72rem; color: var(--ink-soft);
    padding: 0 .5rem; border-right: 1px solid var(--line); border-bottom: 1px dotted var(--line);
    display: flex; align-items: flex-start; justify-content: flex-end; background: var(--paper);
}
.grid__cell { border-bottom: 1px dotted var(--line); border-right: 1px solid var(--line); min-height: 30px; padding: 2px; }
.grid__cell.is-over { background: #f6efe2; outline: 1px dashed var(--brass); }
.placed {
    font-size: .74rem; padding: .2rem .35rem; border-radius: 4px; margin-bottom: 2px;
    background: var(--ink); color: #fff; cursor: grab; display: flex; justify-content: space-between; gap: .25rem;
}
.placed__x { cursor: pointer; opacity: .7; }
.placed__x:hover { opacity: 1; }

/* reminders */
.reminders { grid-column: 1 / -1; margin-top: .5rem; }
.reminders ul { list-style: none; margin: .5rem 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: .4rem; }
.reminders li { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .3rem .55rem; font-size: .82rem; display: flex; gap: .4rem; align-items: center; }

@media (max-width: 900px) { .planner { grid-template-columns: 1fr; } }

/* ============================================================================
   Settings / lists / billing
   ========================================================================== */
.page { display: grid; gap: 1.5rem; max-width: 760px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem 1.4rem; }
.panel > h2 { margin-bottom: .25rem; }
.panel > .muted { margin-bottom: 1rem; }
.row { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .55rem 0; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row__main { display: flex; align-items: center; gap: .6rem; flex: 1; min-width: 0; }
.row__text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.swatch { width: 16px; height: 16px; border-radius: 4px; border: 1px solid rgba(0,0,0,.15); flex: none; }
.inline-add { display: flex; gap: .5rem; margin-top: .9rem; }
.inline-add input[type="text"] { flex: 1; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem 1.25rem; }
.stat { display: flex; align-items: baseline; gap: .5rem; }
.stat__big { font-family: var(--font-display); font-size: 2rem; }
.tag { font-family: var(--font-mono); font-size: .72rem; padding: .15rem .45rem; border-radius: 999px; }
.tag--ok { background: #e7f2ec; color: var(--ok); }
.tag--off { background: #f0ede8; color: var(--ink-soft); }
@media (max-width: 620px) { .grid2 { grid-template-columns: 1fr; } }

/* ============================================================================
   Single-board planner (all phases visible; locks per phase)
   ========================================================================== */
.pboard { display: grid; grid-template-columns: 260px 150px 1fr 230px; gap: 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); font-size: .8rem; }
@media (max-width: 1200px) { .pboard { grid-template-columns: 220px 120px 1fr 200px; } }
.pcol { border-right: 1px solid var(--line); }
.pcol:last-child { border-right: 0; }
.pcol__head { background: #262a44; color: #fff; font-weight: 600; text-align: center; padding: .45rem; font-size: .78rem; position: sticky; top: 0; z-index: 3; }

/* roles+goals column */
.rgroup { border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 26px 1fr; }
.rband { writing-mode: initial; background: #2a2f4a; color: #fff; display: flex; align-items: center; justify-content: center; padding: .2rem; }
.rband span { font-size: .62rem; font-weight: 600; text-align: center; }
.rgoals { display: grid; }
.rgrow { border-bottom: 1px dotted var(--line); padding: 2px 4px; min-height: 30px; display: flex; align-items: center; gap: 4px; }
.rgrow:last-child { border-bottom: 0; }
.rgrow input { width: 100%; border: 1px solid transparent; background: transparent; font: inherit; padding: 2px 4px; border-radius: 4px; }
.rgrow input:not(:disabled):hover, .rgrow input:not(:disabled):focus { border-color: var(--line); background: #fff; outline: none; }
.rgrow.g-pink  { background: #fbdfe6; }
.rgrow.g-green { background: #dcf0e4; }
.rgrow .cat { font-size: .6rem; color: var(--ink-soft); font-family: var(--font-mono); }

/* role header bar (roles phase) */
.rolehdr { display: flex; align-items: center; justify-content: space-between; padding: .3rem .5rem; font-weight: 600; }
.rolehdr input.rn { border: 0; background: transparent; color: inherit; font: 600 .8rem var(--font-body); width: 55%; }
.rolehdr .rc { display: flex; gap: 4px; align-items: center; }

/* reminders */
.remc { padding: 4px; display: grid; gap: 4px; align-content: start; }
.remc .r { background: #fbeee9; border: 1px solid #f0d5cb; border-radius: 4px; padding: 3px 5px; display: flex; justify-content: space-between; gap: 4px; }
.remc input { width: 100%; border: 1px solid var(--line); border-radius: 4px; padding: 3px 5px; font: inherit; }

/* time grid */
.tgrid { display: grid; }
.tgwrap { overflow: auto; }
.thead { display: grid; position: sticky; top: 0; z-index: 2; }
.thead > div { background: #262a44; color: #fff; text-align: center; padding: .4rem 2px; font-size: .72rem; border-left: 1px solid #3a3f5c; }
.trow { display: grid; }
.ttime { font-family: var(--font-mono); font-size: .66rem; color: #b33; text-align: right; padding: 1px 4px; border-bottom: 1px solid #eee; }
.tday { border-left: 1px solid var(--line); border-bottom: 1px solid #eee; background: #efeff2; position: relative; }
.tday.is-over { background: #f6efe2; outline: 1px dashed var(--brass); }
.placed2 { background: #2a2f4a; color: #fff; border-radius: 3px; padding: 1px 4px; font-size: .68rem; margin: 1px; cursor: grab; overflow: hidden; }

/* priority */
.prio { display: grid; margin-top: 2px; }
.prio__lab { font-family: var(--font-mono); font-size: .62rem; color: var(--brass-ink); padding: 2px 4px; text-align: right; }
.prio__cell { border: 1px solid var(--line); min-height: 22px; background: #efeff2; }
.prio__cell.is-over { background: #f6efe2; }
.prio__head { background: #262a44; color:#fff; text-align:center; font-size:.66rem; padding:2px; }

/* details + recycle */
.dcol { padding: .5rem; display: flex; flex-direction: column; gap: .6rem; }
.dtable { font-size: .78rem; }
.dtable div { display: flex; gap: .4rem; margin-bottom: .25rem; }
.dtable b { color: var(--brass-ink); min-width: 78px; }
.dcol input, .dcol textarea { width: 100%; border: 1px solid var(--line); border-radius: 4px; padding: 3px 5px; font: inherit; }
.recycle2 { margin-top: auto; border: 2px dashed #e0a89b; border-radius: var(--radius); background: #fbeae6; color: var(--danger); text-align: center; padding: 1rem; font-size: .8rem; }
.recycle2.is-over { background: #f2c9bf; }
.pcontrols { display: flex; gap: .5rem; justify-content: flex-end; margin-top: .6rem; }
.locked { opacity: .55; }

/* ---- planner topbar controls + fit ---- */
.topbar__center { display: flex; align-items: center; gap: .8rem; flex: 1; justify-content: center; }
.wklabel { font-family: var(--font-display); font-size: 1rem; }
.psteps { display: flex; gap: .3rem; }
.pstep { font-family: var(--font-mono); font-size: .66rem; padding: .2rem .55rem; border-radius: 999px; background: #eef1f5; color: var(--ink-soft); }
.pstep.is-active { background: var(--brass); color: #fff; }
.wknav { display: flex; gap: .25rem; }
.wknav .btn { padding: .3rem .55rem; font-size: .75rem; }
.planwrap { padding: .5rem; }
.planinner { max-width: 100%; }
.pboard { grid-template-columns: 250px 130px 1fr 210px; }
@media (max-width: 1200px) { .pboard { grid-template-columns: 230px 110px 1fr 190px; } }
.pcol--roles .rolehdr { padding: .3rem .5rem; }
.rgroup { display: block; }         /* drop the empty vertical band */
.addrole { gap: 4px; }
.pcontrols { margin-top: .5rem; }

/* ---- role header bars + cog menu ---- */
.rolebar { display: flex; align-items: center; gap: 6px; padding: .4rem .6rem; font-weight: 600; font-size: .82rem; position: relative; cursor: default; }
.rolebar[draggable="true"] { cursor: grab; }
.rolebar__name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rolebar__cog { background: rgba(255,255,255,.25); border: 0; color: inherit; border-radius: 4px; cursor: pointer; padding: 1px 5px; font-size: .8rem; }
.rolemenu { position: absolute; right: 6px; top: 100%; z-index: 20; background: #fff; color: var(--ink); border: 1px solid var(--line); border-radius: 6px; box-shadow: var(--shadow); padding: 6px; display: grid; gap: 4px; min-width: 150px; }
.rolemenu label { font-size: .72rem; display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.rolemenu .mi { text-align: left; border: 0; background: #f4f5f7; border-radius: 4px; padding: 4px 6px; font-size: .76rem; cursor: pointer; }
.rolemenu .mi:hover { background: #e7ebf0; }

/* topbar controls spacing */
.topbar__center { gap: 1rem; }
.psteps { gap: .35rem; }
.wklabel { margin-right: .2rem; white-space: nowrap; }

/* fit to viewport: only inner regions scroll, headers stay */
.planwrap { padding: .4rem; height: calc(100vh - 52px); overflow: hidden; }
.planinner { height: 100%; display: flex; flex-direction: column; }
.pboard { flex: 1; min-height: 0; align-items: stretch; }
.pcol { overflow: auto; }
.pcol__head { position: sticky; top: 0; }
.ttime { height: 20px !important; }
.tday, .prio__cell { }

/* ---- bold vertical role band + modals ---- */
.rgroup { display: grid; grid-template-columns: 84px 1fr; border-bottom: 1px solid var(--line); position: relative; }
.rgroup.dragging { outline: 2px solid var(--brass); outline-offset: -2px; }
.rband { position: relative; display: flex; align-items: center; justify-content: center; cursor: pointer; padding: 4px 0; }
.rband[draggable="true"] { cursor: grab; }
.rband__name { writing-mode: vertical-rl; transform: rotate(180deg); font-weight: 600; font-size: .74rem; white-space: nowrap; letter-spacing: .02em; }
.rband__cog { position: absolute; right: 2px; bottom: 2px; opacity: 0; transition: opacity .12s; background: rgba(255,255,255,.3); border: 0; color: inherit; border-radius: 4px; cursor: pointer; font-size: .72rem; padding: 0 3px; }
.rband:hover .rband__cog { opacity: 1; }
.rgroup .rgoals { display: grid; }

/* modal */
.modal__overlay { position: fixed; inset: 0; background: rgba(16,20,30,.45); display: grid; place-items: center; z-index: 100; }
.modal__box { background: #fff; border-radius: var(--radius); padding: 1rem 1.1rem; width: min(320px, 92vw); box-shadow: var(--shadow); }
.modal__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .6rem; }
.modal__head h3 { margin: 0; font-size: 1rem; }
.modal__x { border: 0; background: none; font-size: 1.3rem; line-height: 1; cursor: pointer; color: var(--ink-soft); }
.modal__box .btn { width: 100%; }


/* wider vertical role band + colour swatches + modal actions */
.rband__name { writing-mode: vertical-rl; transform: rotate(180deg); font-size: .8rem; font-weight: 700; text-align: center; }
.rband { min-height: 60px; }
.rband__cog { right: 4px; bottom: 4px; font-size: .8rem; padding: 1px 5px; }
.swatches { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.swatch { width: 100%; aspect-ratio: 1; border-radius: 50%; border: 2px solid #e2e6eb; cursor: pointer; }
.swatch.is-sel { border-color: var(--ink); box-shadow: 0 0 0 2px var(--brass); }
.modal__actions { display: flex; gap: .5rem; margin-top: 1rem; }
.modal__actions .btn { flex: 1; }

/* role drag feedback */
.rgroup.dragging { opacity: .5; }
.rgroup.drop-target { outline: 2px dashed var(--brass); outline-offset: -2px; }
.rband { user-select: none; }

/* full-row drop catcher: transparent, only intercepts while a role is being dragged */
.dropcatch { position: absolute; inset: 0; z-index: 5; pointer-events: none; }
body.role-dragging .rgroup .dropcatch { pointer-events: auto; }
