/* Priority Board — mobile-first. One column, big tap targets, warm ground. */

:root {
  --ink: #17211f;
  --ink-soft: #5c6b67;
  --ground: #f6f4f0;
  --card: #ffffff;
  --line: #e3ded6;
  --primary: #1f3d3a;
  --primary-ink: #ffffff;
  --accent: #c8873a;
  --danger: #9c3b2e;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(23, 33, 31, 0.06), 0 6px 18px rgba(23, 33, 31, 0.06);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* --- Chrome ------------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--primary);
  color: var(--primary-ink);
  padding: max(env(safe-area-inset-top), 10px) 14px 0;
}

.topbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 40px;
}

.wordmark {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.wordmark-lg { font-size: 24px; color: var(--primary); margin: 0 0 4px; }

.topbar-actions { display: flex; align-items: center; gap: 8px; }

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  background: transparent;
  color: var(--primary-ink);
  font: inherit;
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
}

.pill:active { background: rgba(255, 255, 255, 0.16); }

.inline { display: inline; margin: 0; }

.tabs { display: flex; gap: 4px; margin-top: 8px; }

.tab {
  flex: 1;
  text-align: center;
  padding: 10px 6px;
  color: rgba(255, 255, 255, 0.75);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  border-bottom: 3px solid transparent;
}

.tab.is-active {
  color: var(--primary-ink);
  border-bottom-color: var(--accent);
}

.page {
  max-width: 720px;
  margin: 0 auto;
  padding: 18px 14px calc(40px + env(safe-area-inset-bottom));
}

.page-heading { font-size: 22px; margin: 0 0 4px; }
.page-intro { margin: 0 0 16px; color: var(--ink-soft); font-size: 14px; }
.empty { color: var(--ink-soft); font-size: 15px; }
.hint { color: var(--ink-soft); font-size: 13px; margin: 6px 0 0; }

.alert {
  background: #fbeceb;
  border: 1px solid #edc9c4;
  color: var(--danger);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin: 0 0 14px;
  font-size: 14px;
}

.toast {
  background: #e9f1ec;
  border: 1px solid #c6ddd0;
  color: #1f4c39;
  border-radius: var(--radius);
  padding: 10px 12px;
  margin: 0 0 14px;
  font-size: 14px;
}

.toast-static { margin-bottom: 12px; }

/* --- Buttons ------------------------------------------------------------ */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 18px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.button-primary {
  background: var(--accent);
  color: #2a1a06;
  box-shadow: var(--shadow);
}

.button-primary:active { transform: translateY(1px); }

.button-quiet {
  background: var(--card);
  border-color: var(--line);
  color: var(--ink);
}

.button-block { width: 100%; }

.link { color: var(--primary); }

.back-link {
  display: inline-block;
  margin-bottom: 12px;
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
  min-height: 44px;
  line-height: 44px;
}

/* --- Login -------------------------------------------------------------- */

.login { display: flex; justify-content: center; padding-top: 8vh; }

.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 24px 20px;
}

.login-heading { font-size: 18px; margin: 0 0 16px; color: var(--ink-soft); font-weight: 600; }
.login-lang { margin: 16px 0 0; text-align: center; font-size: 14px; }

.field { display: block; margin-bottom: 14px; }
.field-label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-soft); margin-bottom: 6px; }

.input {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  font: inherit;
}

.input:focus { outline: 2px solid var(--primary); outline-offset: 1px; }

/* Password field with its reveal button sitting inside the field's box. */
.input-with-button { position: relative; }

.input-with-button .input { padding-right: 52px; }

.reveal {
  position: absolute;
  top: 50%;
  right: 4px;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* `display: flex` above outranks the browser's own [hidden] rule, so without
   this the button would still show for a browser that never runs the script --
   a control that looks live and does nothing. */
.reveal[hidden] { display: none; }

.reveal:active { background: #f0ece5; }
.reveal:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }

.reveal-icon { width: 21px; height: 21px; display: block; }

/* One icon at a time: the crossed-out eye means "it is showing". */
.reveal .reveal-icon-hide,
.reveal[aria-pressed="true"] .reveal-icon-show { display: none; }
.reveal[aria-pressed="true"] .reveal-icon-hide { display: block; }
.reveal[aria-pressed="true"] { color: var(--primary); }

textarea.input { min-height: 90px; resize: vertical; }

/* --- Board -------------------------------------------------------------- */

.board { list-style: none; margin: 0 0 20px; padding: 0; }

.row {
  display: flex;
  align-items: stretch;
  gap: 8px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 10px;
  padding: 8px 8px 8px 4px;
  touch-action: pan-y;
}

.row.is-dragging {
  opacity: 0.92;
  border-color: var(--accent);
  box-shadow: 0 10px 26px rgba(23, 33, 31, 0.18);
}

.rank {
  flex: 0 0 26px;
  align-self: center;
  text-align: center;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

.handle {
  flex: 0 0 32px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  border-radius: 10px;
  cursor: grab;
  touch-action: none;
}

.handle:active { cursor: grabbing; background: #f0ece5; }

.handle-grip {
  width: 16px;
  height: 12px;
  background-image: linear-gradient(var(--ink-soft) 2px, transparent 2px);
  background-size: 100% 5px;
  opacity: 0.65;
}

.row-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  padding: 6px 2px;
  color: inherit;
  text-decoration: none;
  min-height: 44px;
}

.row-title { font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }

.row-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.comment-count {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-soft);
  background: #f1ede6;
  border-radius: 999px;
  padding: 2px 8px;
}

.arrows {
  flex: 0 0 40px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
}

.arrow {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbf9f6;
  color: var(--primary);
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
}

.arrow:active { background: #efe9e0; }
.arrow[disabled] { opacity: 0.35; cursor: default; }

/* --- Chips -------------------------------------------------------------- */

.chip {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.4;
  border: 1px solid;
}

.chip-in_build            { background: #e6f0ea; border-color: #b9d6c6; color: #1d5138; }
.chip-in_preparation      { background: #e9eef6; border-color: #c2cfe3; color: #27446f; }
.chip-waiting_input       { background: #fbeee0; border-color: #e8cba3; color: #7d4b12; }
.chip-waiting_third_party { background: #f4ecf6; border-color: #d9c4de; color: #5c3467; }
.chip-ready_to_start      { background: #eef3e2; border-color: #cfdcaf; color: #4a5c1c; }
.chip-idea                { background: #f1efec; border-color: #ded7cd; color: #55504a; }

/* --- Add panel ---------------------------------------------------------- */

.add-panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 4px 14px;
}

.add-summary {
  min-height: 46px;
  display: flex;
  align-items: center;
  font-weight: 600;
  cursor: pointer;
  color: var(--primary);
}

.add-form { padding: 6px 0 14px; }

/* --- Task sheet --------------------------------------------------------- */

.sheet {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 18px 16px;
}

.sheet-rank { margin: 0; font-size: 13px; font-weight: 700; color: var(--ink-soft); }
.sheet-title { margin: 4px 0 16px; font-size: 20px; overflow-wrap: anywhere; }
.sheet-section { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 14px; }
.sheet-label { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-soft); margin: 0 0 8px; }
.sheet-note { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }

.chip-choices { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }

.chip-choice { display: inline-flex; cursor: pointer; }
.chip-choice input { position: absolute; opacity: 0; width: 0; height: 0; }
.chip-choice .chip { opacity: 0.5; padding: 8px 14px; font-size: 13px; }
.chip-choice input:checked + .chip { opacity: 1; outline: 2px solid var(--primary); outline-offset: 1px; }
.chip-choice input:focus-visible + .chip { outline: 2px solid var(--accent); outline-offset: 2px; }

.comments { list-style: none; margin: 0 0 16px; padding: 0; }

.comment {
  background: #faf8f5;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 8px;
}

.comment-head { margin: 0 0 4px; display: flex; justify-content: space-between; gap: 8px; font-size: 12px; }
.comment-author { font-weight: 700; }
.comment-time { color: var(--ink-soft); }
.comment-body { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }

/* --- Change log --------------------------------------------------------- */

.log { list-style: none; margin: 0; padding: 0; }

.log-entry {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 8px;
}

.log-time { margin: 0 0 4px; font-size: 12px; color: var(--ink-soft); }
.log-text { margin: 0; font-size: 14px; }
.log-author { font-weight: 700; }

/* --- Export ------------------------------------------------------------- */

.export-head { margin-bottom: 12px; }
.export-generated { margin: 0; font-size: 13px; color: var(--ink-soft); }

/* The table is wide content: it scrolls inside its own box so the page body
   never scrolls sideways on a phone. */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-top: 14px;
}

.export-table {
  width: 100%;
  min-width: 340px;
  border-collapse: collapse;
  background: var(--card);
  font-size: 14px;
}

.export-table th,
.export-table td {
  border: 1px solid var(--line);
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
}

.export-table th { background: #efece6; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }

.col-rank { width: 3.2rem; text-align: center; font-variant-numeric: tabular-nums; }
.col-moved { width: 7.5rem; white-space: nowrap; }

@media (max-width: 430px) {
  /* On a phone the four columns are made to FIT rather than to scroll -- a
     clipped last column reads as broken even when the box scrolls. */
  .export-table { font-size: 12px; min-width: 0; }
  .export-table th,
  .export-table td { padding: 6px 5px; }
  .export-table th { font-size: 10px; letter-spacing: 0; }
  .col-rank { width: 2rem; }
  .col-chip { width: 5.6rem; }
  .col-moved { width: 5.2rem; white-space: normal; }
}

/* --- Print (A4) --------------------------------------------------------- */

@page { size: A4 portrait; margin: 16mm; }

@media print {
  .topbar,
  .no-print,
  .back-link { display: none !important; }

  body { background: #fff; font-size: 11pt; }
  .page { max-width: none; padding: 0; }
  .page-heading { font-size: 16pt; }
  .export-table { font-size: 10pt; box-shadow: none; }
  .export-table th { background: #eee !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .export-table tr { break-inside: avoid; }
  thead { display: table-header-group; }
}
