/* Project Ideas - one stylesheet, no framework.
   Laid out mobile-first; the wider layout comes in at 720px. */

:root {
  --bg: #f7f6f3;
  --surface: #ffffff;
  --surface-2: #f1efea;
  --text: #1d1d1f;
  --text-dim: #6b6a66;
  --line: #e2dfd8;
  --accent: #3f6cff;
  --accent-text: #ffffff;
  --danger: #c0392b;
  --shadow: 0 1px 2px rgba(20, 20, 20, .06), 0 8px 24px rgba(20, 20, 20, .06);

  --st-idea: #6b6a66;
  --st-progress: #c98a1b;
  --st-paused: #7b7fa8;
  --st-finished: #2f9e63;
  --st-abandoned: #a8635c;

  --easy: #2f9e63;
  --medium: #c98a1b;
  --hard: #cf5a2c;
  --epic: #a03a86;
  --trivial: #4a8fb5;

  --radius: 14px;
  --gap: 16px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16161a;
    --surface: #202027;
    --surface-2: #2a2a32;
    --text: #ececf1;
    --text-dim: #9b9ba6;
    --line: #33333d;
    --accent: #7d9bff;
    --accent-text: #10101a;
    --danger: #ff8071;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .35);

    --st-idea: #9b9ba6;
    --st-progress: #e0ae53;
    --st-paused: #a3a7d0;
    --st-finished: #56c98a;
    --st-abandoned: #d08e87;

    --easy: #56c98a;
    --medium: #e0ae53;
    --hard: #ef8a60;
    --epic: #d179bd;
    --trivial: #74b7db;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  /* room for the floating button on phones */
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
}

h1, h2 { margin: 0; font-weight: 650; letter-spacing: -.01em; }

/* --- top bar ---------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 16px;
  padding-top: calc(14px + env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.topbar__title { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.topbar h1 { font-size: 1.35rem; }
.count { margin: 0; color: var(--text-dim); font-size: .85rem; }

/* Ideas / Trash switch */
.viewswitch {
  display: flex;
  gap: 2px;
  padding: 3px;
  border-radius: 999px;
  background: var(--surface-2);
  /* Its own full-width row on a phone - three tabs will not fit next to the
     title. It goes back beside the title at 720px. */
  flex: 1 0 100%;
  margin-top: 2px;
}
.viewswitch__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  flex: 1 1 0;
  min-width: 0;
  font: inherit;
  font-size: .82rem;
  font-weight: 550;
  color: var(--text-dim);
  padding: 6px 12px;
  min-height: 34px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  white-space: nowrap;
}
.viewswitch__btn.is-on {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .12);
}
.icon {
  width: 16px; height: 16px;
  stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
  fill: none;
}
.viewswitch__btn .icon { width: 15px; height: 15px; }

.density { flex: 0 0 auto; display: inline-grid; place-items: center; padding: 10px; }
.density.is-on { background: var(--surface-2); }
.badge {
  font-size: .72rem;
  font-weight: 700;
  min-width: 18px;
  padding: 1px 5px;
  border-radius: 999px;
  background: var(--text-dim);
  color: var(--bg);
  text-align: center;
}
.viewswitch__btn.is-on .badge { background: var(--danger); color: #fff; }

.topbar__controls { display: flex; gap: 8px; min-width: 0; }
.search { flex: 1 1 auto; min-width: 0; }
/* width:auto matters: .input sets width:100%, which a flex item takes as its
   basis - the select would otherwise fill the whole bar and push the rest off
   the side of the screen. */
.select { flex: 0 1 auto; width: auto; min-width: 0; max-width: 48%; }
.new-btn { display: none; }   /* phones use the floating button instead */
[hidden] { display: none !important; }

/* --- form controls ---------------------------------------------------- */

.input {
  width: 100%;
  padding: 10px 12px;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  min-height: 44px;            /* comfortable touch target */
  -webkit-appearance: none;
  appearance: none;
}
.input:focus-visible,
.btn:focus-visible,
.range:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
textarea.input { min-height: 96px; resize: vertical; line-height: 1.45; }
select.input, .select {
  background-image: linear-gradient(45deg, transparent 50%, var(--text-dim) 50%),
                    linear-gradient(135deg, var(--text-dim) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 34px;
}

.btn {
  font: inherit;
  font-weight: 550;
  padding: 10px 16px;
  min-height: 44px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { filter: brightness(.97); }
.btn--primary { background: var(--accent); color: var(--accent-text); }
.btn--ghost { background: transparent; border-color: var(--line); }
.btn--danger { color: var(--danger); }
.btn--danger-solid { background: var(--danger); color: #fff; }
.btn[disabled] { opacity: .55; cursor: default; }
.icon-btn { padding: 6px 10px; min-height: 36px; border: 0; font-size: 1rem; }

/* --- the grid of ideas ------------------------------------------------ */

.page { max-width: 1180px; margin: 0 auto; padding: var(--gap); }

.grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--gap);
  grid-template-columns: 1fr;
  min-width: 0;
}

.card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 0;
}

.card--trashed {
  background: transparent;
  border-style: dashed;
  box-shadow: none;
}
.card--trashed .card__name,
.card--trashed .card__desc { color: var(--text-dim); }
.card--trashed .meter__bars i.on { background: var(--text-dim); }

.card__head { display: flex; align-items: baseline; gap: 10px; justify-content: space-between; }
.card__name { font-size: 1.05rem; overflow-wrap: anywhere; }

/* Difficulty reads as a quiet caption; interest as the one number worth
   scanning down the column. */
.card__meta {
  flex: 0 0 auto;
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: .8rem;
}
.card__difficulty { color: var(--text-dim); }
.card__interest {
  font-weight: 700;
  font-size: .95rem;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.card__desc {
  margin: 0;
  color: var(--text-dim);
  font-size: .93rem;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

/* Cut off after three lines - the whole description is in the detail window.
   line-clamp needs the -webkit- box model, which every current browser keeps
   supporting for exactly this. */
.card__desc--clamped {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
}

/* The card is one big button now. */
.card { cursor: pointer; }
.card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.card__actions .btn { cursor: pointer; }

.pill {
  flex: 0 0 auto;
  font-size: .72rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 4px 9px;
  border-radius: 999px;
  color: var(--pill, var(--text-dim));
  background: color-mix(in srgb, var(--pill, var(--text-dim)) 14%, transparent);
}
/* Colour carries one meaning only: status. Difficulty is deliberately plain,
   so a coloured tag always means "something is happening here". */
.pill--difficulty { --pill: var(--text-dim); }

.pill--status { align-self: flex-start; }
.pill[data-status="idea"]        { --pill: var(--st-idea); }
.pill[data-status="in_progress"] { --pill: var(--st-progress); }
.pill[data-status="paused"]      { --pill: var(--st-paused); }
.pill[data-status="finished"]    { --pill: var(--st-finished); }
.pill[data-status="abandoned"]   { --pill: var(--st-abandoned); }

.chips { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; }
.chips li {
  font-size: .78rem;
  overflow-wrap: anywhere;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-dim);
}

/* interest, as ten little bars */
.meter { display: flex; align-items: center; gap: 8px; font-size: .78rem; color: var(--text-dim); }
.meter__label { flex: 0 0 auto; }
.meter__bars { display: flex; gap: 3px; flex: 1 1 auto; }
.meter__bars i {
  flex: 1 1 auto;
  height: 6px;
  max-width: 14px;
  border-radius: 2px;
  background: var(--surface-2);
}
.meter__bars i.on { background: var(--accent); }
.meter__value { flex: 0 0 auto; font-variant-numeric: tabular-nums; font-weight: 600; color: var(--text); }

/* Progress bar. Shown on a card only while the status is in_progress, and
   given room to breathe in the stacked In progress view. */
.progress { display: flex; align-items: center; gap: 10px; }
.progress__track {
  flex: 1 1 auto;
  height: 8px;
  min-width: 0;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}
.progress__fill {
  height: 100%;
  border-radius: 999px;
  background: var(--st-progress);
  transition: width .25s ease;
}
.progress__value {
  flex: 0 0 auto;
  font-size: .8rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--st-progress);
  min-width: 3.2ch;
  text-align: right;
}
@media (prefers-reduced-motion: reduce) {
  .progress__fill { transition: none; }
}

.card__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.card__date { color: var(--text-dim); font-size: .78rem; }
.card__actions { display: flex; gap: 4px; }
.card__actions .btn { padding: 6px 10px; min-height: 36px; font-size: .85rem; }

/* The In progress view: one idea per row, full width, bars aligned. */
.grid--stack {
  grid-template-columns: 1fr;
  grid-auto-rows: auto;
  max-width: 860px;
  margin: 0 auto;
}
.grid--stack .progress { margin-block: 2px 4px; }
.grid--stack .progress__track { height: 12px; }
.grid--stack .progress__value { font-size: .95rem; min-width: 4ch; }
.grid--stack .card__desc--clamped { -webkit-line-clamp: 2; line-clamp: 2; }

/* Status filter chips */
.filters {
  display: flex;
  gap: 6px;
  margin-bottom: var(--gap);
  overflow-x: auto;              /* a phone scrolls them instead of wrapping */
  scrollbar-width: none;
  padding-bottom: 2px;
}
.filters::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: inherit;
  font-size: .82rem;
  font-weight: 550;
  color: var(--text-dim);
  padding: 6px 12px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  white-space: nowrap;
}
.chip:hover { border-color: var(--text-dim); }
.chip.is-on {
  background: var(--text);
  border-color: var(--text);
  color: var(--bg);
}
.chip__count { font-variant-numeric: tabular-nums; opacity: .65; }

/* List density: one tight row per idea. Same markup, different shape. */
.grid--list { gap: 0; grid-auto-rows: auto; }
.grid--list .card {
  flex-direction: row;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 0;
  border-width: 0 0 1px 0;
  box-shadow: none;
  background: transparent;
}
.grid--list .card:first-child { border-top: 1px solid var(--line); }
.grid--list .card:hover { background: var(--surface); }
.grid--list .card__head { flex: 1 1 auto; min-width: 0; gap: 8px; }
.grid--list .card__name {
  font-size: .96rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.grid--list .card__meta { order: 2; }
.grid--list .card__desc,
.grid--list .chips,
.grid--list .card__foot { display: none; }
.grid--list .pill--status { order: 3; align-self: center; }
.grid--list .progress { order: 4; flex: 0 0 110px; }
.grid--list .progress__track { height: 6px; }

.empty {
  text-align: center;
  color: var(--text-dim);
  padding: 56px 20px;
  margin: 0;
}

/* --- floating action button (phones) ---------------------------------- */

.fab {
  position: fixed;
  right: 18px;
  bottom: calc(18px + env(safe-area-inset-bottom));
  z-index: 6;
  width: 58px;
  height: 58px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-text);
  box-shadow: 0 6px 20px rgba(0, 0, 0, .25);
  cursor: pointer;
  display: grid;
  place-items: center;
}
.fab svg { width: 26px; height: 26px; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; fill: none; }

/* --- dialogs: bottom sheet on phones, centred card on desktop ---------- */

.sheet {
  border: 0;
  padding: 0;
  background: transparent;
  width: 100%;
  max-width: 100%;
  max-height: 100%;
  margin: 0;
  position: fixed;
  inset: auto 0 0 0;           /* stuck to the bottom edge */
  color: var(--text);
}
.sheet::backdrop { background: rgba(0, 0, 0, .45); backdrop-filter: blur(2px); }

.form {
  display: flex;
  flex-direction: column;
  max-height: 92vh;
  max-height: 92dvh;
  background: var(--surface);
  border-top-left-radius: 18px;
  border-top-right-radius: 18px;
  border: 1px solid var(--line);
}

.form__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}
.form__head h2 { font-size: 1.05rem; }

.form__body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.form__foot {
  display: flex;
  gap: 8px;
  padding: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.form__foot .btn { flex: 1 1 auto; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field__label { font-size: .85rem; font-weight: 600; }
.field__hint { font-size: .78rem; color: var(--text-dim); font-weight: 400; }
.field__out { font-variant-numeric: tabular-nums; color: var(--accent); font-weight: 700; }
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1 1 0; min-width: 0; }

.range {
  width: 100%;
  height: 32px;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
}
.range::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: var(--surface-2); }
.range::-moz-range-track { height: 6px; border-radius: 3px; background: var(--surface-2); }
.range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 26px; height: 26px;
  margin-top: -10px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--surface);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .3);
}
.range::-moz-range-thumb {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--surface);
}

.form__error {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: .88rem;
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 12%, transparent);
}
.detail__pills { display: flex; flex-wrap: wrap; gap: 6px; }
.detail__desc {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.55;
}
.detail__row { display: flex; flex-direction: column; gap: 6px; }
.detail__label {
  font-size: .75rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-dim);
}
.detail__value { font-size: .93rem; }
.chips__none { font-style: italic; opacity: .8; }
#detail-actions { justify-content: flex-end; }

.confirm__text { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.confirm__warning {
  margin: 10px 0 0;
  font-size: .85rem;
  color: var(--danger);
}

/* --- toast ------------------------------------------------------------ */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 20;
  max-width: min(92vw, 460px);
  padding: 12px 16px;
  border-radius: 12px;
  background: #1d1d1f;
  color: #fff;
  font-size: .9rem;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .35);
}
.toast[data-kind="error"] { background: var(--danger); color: #fff; }

/* --- wider screens ---------------------------------------------------- */

@media (min-width: 720px) {
  body { padding-bottom: 40px; }

  .topbar {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 16px 28px;
    /* The single row needs roughly 980px for title + tabs + controls. Below
       that it wraps to two rows rather than pushing New idea off the edge. */
    flex-wrap: wrap;
  }
  .topbar__controls { flex: 1 1 440px; }
  .topbar h1 { font-size: 1.5rem; }
  .search { min-width: 200px; }
  .new-btn { display: inline-block; }
  .fab { display: none; }

  .viewswitch { flex: 0 0 auto; margin-top: 0; margin-left: 10px; }
  .viewswitch__btn { flex: 0 0 auto; }

  .page { padding: 28px; }
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr));
    /* Equal heights only where there are columns to line up. On a phone it
       would just pad every card with dead space. */
    grid-auto-rows: 1fr;
  }
  /* ...except the stacked and list views, which stay one per row at every
     width. The doubled class outweighs the .grid rule just above. */
  .grid.grid--stack,
  .grid.grid--list { grid-template-columns: 1fr; grid-auto-rows: auto; }

  /* dialogs become a centred card */
  .sheet { inset: 0; margin: auto; width: min(560px, 92vw); }
  .sheet--small { width: min(420px, 92vw); }
  .form { border-radius: 18px; max-height: 86vh; }
  .form__foot { justify-content: flex-end; padding-bottom: 16px; }
  .form__foot .btn { flex: 0 0 auto; }
}

@media (prefers-reduced-motion: no-preference) {
  .card, .btn, .fab { transition: filter .15s ease, transform .15s ease, box-shadow .15s ease; }
  .card:hover { box-shadow: 0 2px 4px rgba(20, 20, 20, .07), 0 12px 34px rgba(20, 20, 20, .09); }
  .fab:active { transform: scale(.93); }
}

/* --- signing in --------------------------------------------------------
   One centred card. Reuses .input, .btn and .field from the idea form, so
   the sign-in page is recognisably the same app before you are even in. */

.signin-body {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 16px calc(24px + env(safe-area-inset-bottom));
}

.signin { width: 100%; }

.signin__card {
  width: min(400px, 100%);
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 28px 24px 22px;
  text-align: center;
}

.signin__mark { display: block; margin: 0 auto 14px; border-radius: 12px; }
.signin__title { font-size: 1.3rem; margin-bottom: 4px; }

.signin__sub {
  color: var(--text-dim);
  font-size: .9rem;
  margin-bottom: 20px;
}

.signin__form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: left;
}

.signin__submit { width: 100%; justify-content: center; margin-top: 4px; }

.signin__error {
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent);
  color: var(--danger);
  border-radius: 10px;
  padding: 9px 11px;
  font-size: .85rem;
  margin: 0;
}

/* color-mix is recent; anywhere it is missing the message still reads as an
   error, just without the tint. */
@supports not (background: color-mix(in srgb, red 10%, transparent)) {
  .signin__error { background: transparent; border-color: var(--danger); }
}

.signin__switch { margin: 16px 0 0; min-height: 1.2em; }

.linkish {
  background: none;
  border: 0;
  padding: 4px;
  font: inherit;
  font-size: .85rem;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.linkish:hover { filter: brightness(1.1); }
.linkish:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* --- who is signed in --------------------------------------------------
   Sits at the end of the top bar's controls. On a narrow screen the username
   goes away and only the sign-out button is left. */

.account {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  padding-left: 8px;
  min-width: 0;
}

.account__name {
  font-size: .85rem;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 12ch;
}

@media (max-width: 560px) {
  .account__name { display: none; }
}
