/* Lelet: warm paper, ink, one red accent. Green is used only for "matches plan" data. System fonts only. */

:root {
  --paper: #f4efe6;
  --surface: #fbf8f2;
  --ink: #1b1a17;
  --ink-2: #5a554c;
  --rule: #d8cfbf;
  --accent: #d9381e;
  --accent-ink: #b32a12;
  --on-accent: #ffffff;
  --ok: #1f7a3d;
  --warn-bg: #f6e3c8;
  --receipt: #fffdf8;
  --shadow: 0 1px 0 rgba(27, 26, 23, 0.06), 0 10px 30px -18px rgba(27, 26, 23, 0.45);
  --serif: 'Iowan Old Style', 'Palatino Linotype', Palatino, 'Book Antiqua', Georgia, serif;
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --mono: ui-monospace, 'Cascadia Mono', 'SF Mono', Consolas, Menlo, 'Liberation Mono', monospace;
  --radius: 10px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --paper: #161513;
    --surface: #211f1c;
    --ink: #efe9dd;
    --ink-2: #aaa294;
    --rule: #3a362f;
    --accent: #e8492c;
    --accent-ink: #ff8a70;
    --on-accent: #ffffff;
    --ok: #6cc98a;
    --warn-bg: #3b2d18;
    --receipt: #262420;
    --shadow: 0 1px 0 rgba(0, 0, 0, 0.3), 0 10px 30px -18px rgba(0, 0, 0, 0.9);
    color-scheme: dark;
  }
}

:root[data-theme='dark'] {
  --paper: #161513;
  --surface: #211f1c;
  --ink: #efe9dd;
  --ink-2: #aaa294;
  --rule: #3a362f;
  --accent: #e8492c;
  --accent-ink: #ff8a70;
  --on-accent: #ffffff;
  --ok: #6cc98a;
  --warn-bg: #3b2d18;
  --receipt: #262420;
  --shadow: 0 1px 0 rgba(0, 0, 0, 0.3), 0 10px 30px -18px rgba(0, 0, 0, 0.9);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.55 var(--sans);
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}

h1,
h2,
h3 {
  font-family: var(--serif);
  font-weight: 700;
  line-height: 1.15;
  margin: 0;
  letter-spacing: -0.01em;
}

h1 {
  font-size: clamp(2rem, 8vw, 3.1rem);
}

h2 {
  font-size: 1.25rem;
}

p {
  margin: 0;
}

a {
  color: var(--accent-ink);
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.skip {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--ink);
  color: var(--paper);
  padding: 8px 12px;
  z-index: 20;
}

.skip:focus {
  left: 8px;
  top: 8px;
}

/* ---------- header ---------- */

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 760px;
  margin: 0 auto;
  padding: 14px 18px 6px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--ink);
  text-decoration: none;
  min-width: 0;
}

.mark {
  width: 28px;
  height: 28px;
  flex: none;
}

.mark-ghost {
  fill: var(--rule);
}

.mark-solid {
  fill: var(--accent);
}

.brand-name {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
}

.brand-tag {
  color: var(--ink-2);
  font-size: 0.8rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-actions {
  display: flex;
  gap: 8px;
  flex: none;
}

.chip {
  min-width: 44px;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: transparent;
  font-family: var(--mono);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.chip svg {
  width: 18px;
  height: 18px;
  fill: var(--ink);
  stroke: var(--ink);
}

.chip:hover {
  border-color: var(--ink);
}

/* ---------- tabs: bottom bar on phones, under the header on wide screens ---------- */

.tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--surface);
  border-top: 1px solid var(--rule);
  padding-bottom: env(safe-area-inset-bottom);
}

.tabs a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 60px;
  color: var(--ink-2);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 600;
  border-top: 3px solid transparent;
}

.tabs .step {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
}

.tabs a[aria-current='page'] {
  color: var(--ink);
  border-top-color: var(--accent);
}

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

  .tabs {
    position: static;
    max-width: 760px;
    margin: 4px auto 0;
    padding: 0 18px;
    background: transparent;
    border-top: 0;
    border-bottom: 1px solid var(--rule);
  }

  .tabs a {
    flex-direction: row;
    gap: 8px;
    min-height: 48px;
    border-top: 0;
    border-bottom: 3px solid transparent;
    margin-bottom: -1px;
  }

  .tabs a[aria-current='page'] {
    border-bottom-color: var(--accent);
  }
}

/* ---------- layout ---------- */

main {
  max-width: 760px;
  margin: 0 auto;
  padding: 18px 18px 8px;
  outline: none;
}

.stack > * + * {
  margin-top: 18px;
}

.lead {
  color: var(--ink-2);
  font-size: 1.05rem;
  max-width: 34em;
  margin-top: 10px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 18px;
}

.small {
  font-size: 0.86rem;
  color: var(--ink-2);
}

.mono {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 18px;
  border-radius: var(--radius);
  border: 1px solid var(--ink);
  background: transparent;
  font-weight: 600;
  text-decoration: none;
  color: var(--ink);
  cursor: pointer;
}

.btn:hover {
  background: var(--ink);
  color: var(--paper);
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
  font-size: 1.08rem;
  min-height: 56px;
  width: 100%;
}

.btn.primary:hover {
  background: var(--accent-ink);
  border-color: var(--accent-ink);
  color: var(--on-accent);
}

:root[data-theme='dark'] .btn.primary:hover {
  background: #c93a20;
  border-color: #c93a20;
}

.btn.quiet {
  border-color: var(--rule);
  min-height: 44px;
  font-weight: 500;
  font-size: 0.92rem;
}

.btn.danger {
  border-color: var(--rule);
  color: var(--accent-ink);
  min-height: 44px;
  font-size: 0.92rem;
}

.btn.danger:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.row > .btn {
  flex: 1 1 150px;
}

/* ---------- meter ---------- */

.meter {
  text-align: left;
}

.meter-label {
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-2);
}

.meter-num {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-top: 2px;
}

.meter-num b {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: clamp(3.4rem, 19vw, 5.6rem);
  line-height: 1;
  letter-spacing: -0.04em;
}

.meter-num span {
  font-family: var(--mono);
  color: var(--ink-2);
  font-size: 1.05rem;
}

.promise {
  margin-top: 14px;
}

.promise-track {
  position: relative;
  height: 14px;
  background: var(--rule);
  border-radius: 3px;
  overflow: hidden;
}

.promise-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  background: var(--accent);
  transition: width 0.4s ease;
}

.promise-fill.ok {
  background: var(--ok);
}

.promise-mark {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 80%;
  width: 2px;
  background: var(--ink);
  opacity: 0.55;
}

.promise-text {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 6px;
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--ink-2);
}

.promise-text strong {
  color: var(--ink);
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  margin-top: 16px;
  border-top: 1px dashed var(--rule);
}

.stats div {
  padding: 10px 0 0;
}

.stats dt {
  font-size: 0.78rem;
  color: var(--ink-2);
}

.stats dd {
  margin: 0;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 1.05rem;
  font-weight: 600;
}

.stats dd small {
  font-weight: 400;
  color: var(--ink-2);
  font-size: 0.72rem;
}

.phase {
  min-height: 1.5em;
  margin-top: 10px;
  font-size: 0.92rem;
  color: var(--ink-2);
}

.progress {
  height: 4px;
  background: var(--rule);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 8px;
}

.progress i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--ink);
  transition: width 0.25s linear;
}

/* ---------- verdict ---------- */

.verdict {
  border-left: 5px solid var(--accent);
  background: var(--surface);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 14px 16px;
}

.verdict.ok {
  border-left-color: var(--ok);
}

.verdict h2 {
  color: var(--accent-ink);
}

.verdict.ok h2 {
  color: var(--ok);
}

.verdict .rp {
  font-size: 1.08rem;
  font-weight: 600;
  margin-top: 8px;
}

.verdict .rp b {
  font-family: var(--mono);
  white-space: nowrap;
}

.verdict .btn {
  margin-top: 14px;
}

/* ---------- forms ---------- */

.field {
  display: block;
}

.field + .field {
  margin-top: 14px;
}

.field > span {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 5px;
}

.field em {
  font-style: normal;
  font-weight: 400;
  color: var(--ink-2);
}

input[type='text'],
input[type='number'],
input[type='date'],
textarea {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  background: var(--receipt);
  border: 1px solid var(--rule);
  border-radius: 8px;
}

input:focus,
textarea:focus {
  border-color: var(--ink);
}

.two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.two .field + .field {
  margin-top: 0;
}

fieldset {
  border: 0;
  padding: 0;
  margin: 0;
  min-width: 0;
}

legend {
  padding: 0;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.seg {
  display: flex;
  border: 1px solid var(--rule);
  border-radius: 8px;
  overflow: hidden;
  background: var(--receipt);
}

.seg button {
  flex: 1 1 0;
  min-width: 0;
  min-height: 46px;
  padding: 4px 6px;
  border: 0;
  border-left: 1px solid var(--rule);
  background: transparent;
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1.2;
}

.seg button:first-child {
  border-left: 0;
}

.seg button small {
  display: block;
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--ink-2);
}

.seg button[aria-pressed='true'] {
  background: var(--ink);
  color: var(--paper);
  font-weight: 600;
}

.seg button[aria-pressed='true'] small {
  color: var(--paper);
  opacity: 0.8;
}

.settings > * + * {
  margin-top: 16px;
}

.hint {
  font-size: 0.84rem;
  color: var(--ink-2);
  margin-top: 6px;
}

.card > .hint + .field {
  margin-top: 14px;
}

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

/* ---------- notices ---------- */

.notice {
  background: var(--warn-bg);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 0.94rem;
}

.notice.plain {
  background: transparent;
  border: 1px dashed var(--rule);
}

.notice .btn {
  margin-top: 10px;
}

/* ---------- evidence strip + checklist ---------- */

.strength-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.level {
  font-family: var(--mono);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-size: 0.9rem;
  padding: 2px 8px;
  border: 2px solid currentColor;
  border-radius: 4px;
  color: var(--accent-ink);
}

.level.kuat {
  color: var(--ok);
}

.level.cukup {
  color: var(--ink);
}

.checks {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
}

.checks li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
  align-items: center;
  padding: 7px 0;
  border-top: 1px dashed var(--rule);
  font-size: 0.92rem;
}

.checks .count {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.checks .done .count {
  color: var(--ok);
}

.checks .bar {
  grid-column: 1 / -1;
  height: 4px;
  background: var(--rule);
  border-radius: 2px;
  overflow: hidden;
}

.checks .bar i {
  display: block;
  height: 100%;
  background: var(--ink);
}

.checks .done .bar i {
  background: var(--ok);
}

.next {
  margin-top: 10px;
  font-weight: 600;
}

/* ---------- receipt: the signature element ---------- */

.receipt {
  position: relative;
  max-width: 420px;
  margin-left: auto;
  margin-right: auto;
  background: var(--receipt);
  color: var(--ink);
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.9rem;
  padding: 26px 20px 30px;
  box-shadow: var(--shadow);
  clip-path: polygon(0% 0, 2.5% 8px, 5% 0, 7.5% 8px, 10% 0, 12.5% 8px, 15% 0, 17.5% 8px, 20% 0, 22.5% 8px, 25% 0, 27.5% 8px, 30% 0, 32.5% 8px, 35% 0, 37.5% 8px, 40% 0, 42.5% 8px, 45% 0, 47.5% 8px, 50% 0, 52.5% 8px, 55% 0, 57.5% 8px, 60% 0, 62.5% 8px, 65% 0, 67.5% 8px, 70% 0, 72.5% 8px, 75% 0, 77.5% 8px, 80% 0, 82.5% 8px, 85% 0, 87.5% 8px, 90% 0, 92.5% 8px, 95% 0, 97.5% 8px, 100% 0, 100% 100%, 97.5% calc(100% - 8px), 95% 100%, 92.5% calc(100% - 8px), 90% 100%, 87.5% calc(100% - 8px), 85% 100%, 82.5% calc(100% - 8px), 80% 100%, 77.5% calc(100% - 8px), 75% 100%, 72.5% calc(100% - 8px), 70% 100%, 67.5% calc(100% - 8px), 65% 100%, 62.5% calc(100% - 8px), 60% 100%, 57.5% calc(100% - 8px), 55% 100%, 52.5% calc(100% - 8px), 50% 100%, 47.5% calc(100% - 8px), 45% 100%, 42.5% calc(100% - 8px), 40% 100%, 37.5% calc(100% - 8px), 35% 100%, 32.5% calc(100% - 8px), 30% 100%, 27.5% calc(100% - 8px), 25% 100%, 22.5% calc(100% - 8px), 20% 100%, 17.5% calc(100% - 8px), 15% 100%, 12.5% calc(100% - 8px), 10% 100%, 7.5% calc(100% - 8px), 5% 100%, 2.5% calc(100% - 8px), 0% 100%);
}

.receipt h2 {
  font-family: var(--mono);
  font-size: 1rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  text-align: center;
}

.receipt .sub {
  text-align: center;
  color: var(--ink-2);
  font-size: 0.78rem;
  margin-top: 4px;
}

.receipt hr {
  border: 0;
  border-top: 1px dashed var(--ink-2);
  margin: 14px 0;
}

.receipt dl {
  margin: 0;
}

.receipt .line {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 3px 0;
}

.receipt dt {
  color: var(--ink-2);
}

.receipt dd {
  margin: 0;
  text-align: right;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.receipt .total {
  font-size: 1.05rem;
  padding: 6px 0;
}

.receipt .total dt {
  color: var(--ink);
  font-weight: 700;
}

.stamp-wrap {
  display: flex;
  justify-content: center;
  margin: 18px 0 4px;
}

.stamp {
  display: inline-block;
  transform: rotate(-4deg);
  border: 3px double var(--accent-ink);
  color: var(--accent-ink);
  padding: 6px 14px;
  font-weight: 700;
  font-size: 1.02rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-align: center;
  border-radius: 4px;
}

.stamp.ok {
  border-color: var(--ok);
  color: var(--ok);
}

.stamp.none {
  border-color: var(--ink-2);
  color: var(--ink-2);
}

.sample-flag {
  text-align: center;
  font-weight: 700;
  letter-spacing: 0.3em;
  color: var(--accent-ink);
  margin-bottom: 10px;
}

/* ---------- table ---------- */

.table-wrap {
  position: relative;
  overflow-x: auto;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.84rem;
}

th,
td {
  padding: 9px 5px;
  text-align: right;
  white-space: nowrap;
  border-bottom: 1px solid var(--rule);
}

th:first-child,
td:first-child {
  text-align: left;
  padding-left: 12px;
}

th {
  font-family: var(--sans);
  font-size: 0.76rem;
  color: var(--ink-2);
  font-weight: 600;
}

tr:last-child td {
  border-bottom: 0;
}

td.low {
  color: var(--ink-2);
}

.del {
  width: 36px;
  height: 36px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
  font-family: var(--mono);
  font-size: 1rem;
}

.del:hover {
  border-color: var(--accent);
  color: var(--accent-ink);
}

/* ---------- letter ---------- */

textarea.letter {
  min-height: 420px;
  font-family: var(--mono);
  font-size: 0.86rem;
  line-height: 1.5;
  resize: vertical;
  white-space: pre-wrap;
}

textarea.letter.short {
  min-height: 190px;
}

ol.where {
  margin: 10px 0 0;
  padding-left: 1.3em;
}

ol.where li + li {
  margin-top: 6px;
}

/* ---------- after the letter is sent ---------- */

#follow > .btn,
#follow > .row {
  margin-top: 14px;
}

.follow-sent {
  margin-top: 8px;
  font-family: var(--mono);
  font-size: 0.86rem;
  color: var(--ink-2);
}

.follow-status {
  margin-top: 6px;
  padding-left: 12px;
  border-left: 3px solid var(--rule);
  font-weight: 600;
}

.follow-status.over {
  border-left-color: var(--accent);
}

details {
  border-top: 1px solid var(--rule);
  padding-top: 12px;
}

#follow > details,
#follow > .late-ticket {
  margin-top: 16px;
}

.late-ticket .btn {
  margin-top: 10px;
}

#follow-count .hint + .hint {
  margin-top: 4px;
}

pre.sent-text {
  margin: 10px 0 0;
  padding: 12px;
  max-height: 320px;
  overflow: auto;
  border: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

#follow details > .row {
  margin-top: 12px;
}

/* a text box used only to copy text on browsers without the clipboard API */
.offscreen {
  position: fixed;
  top: 0;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
}

summary {
  cursor: pointer;
  font-weight: 600;
  min-height: 32px;
}

details ul {
  margin: 8px 0 0;
  padding-left: 1.2em;
  color: var(--ink-2);
  font-size: 0.94rem;
}

details li + li {
  margin-top: 6px;
}

/* ---------- footer, toast ---------- */

.foot {
  max-width: 760px;
  margin: 26px auto 0;
  padding: 16px 18px 28px;
  border-top: 1px solid var(--rule);
  font-size: 0.82rem;
  color: var(--ink-2);
}

.foot p + p {
  margin-top: 6px;
}

.foot .btn {
  margin-top: 6px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(84px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(12px);
  background: var(--ink);
  color: var(--paper);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 0.9rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  max-width: calc(100vw - 32px);
  z-index: 30;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.print-letter {
  display: none;
}

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

@media (max-width: 380px) {
  .brand-tag {
    display: none;
  }

  .two {
    grid-template-columns: 1fr;
  }

  .two .field + .field {
    margin-top: 14px;
  }
}

/* ---------- print: only the letter ---------- */

@media print {
  body {
    background: #fff;
    color: #000;
    padding: 0;
  }

  body > *:not(.print-letter) {
    display: none !important;
  }

  .print-letter {
    display: block;
    font: 11pt/1.5 var(--mono);
    white-space: pre-wrap;
    margin: 0;
  }
}
