/*
  Koyama Studio component kit, v1 (2026-10). Requires tokens.css.
  Source of truth: skill/koyama-mini-app/brand/kit.css. Copy into each app as src/styles/kit.css.
  Signature details: trim marks instead of borders, a square seal marker for "active",
  a square slider thumb, ink buttons, red used only as the seal.
*/

.k-root {
  font-family: var(--font-ui);
  font-size: var(--text-md);
  line-height: 1.45;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

.k-root *,
.k-root *::before,
.k-root *::after { box-sizing: border-box; }

/* A forced theme must also reset the text color, which children inherit as a resolved value */
.k-light,
.k-dark { color: var(--ink); }

/* Icons: Lucide geometry, 24 grid, inherits color */
.k-icon {
  width: 22px;
  height: 22px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Type roles */
.k-display {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-xl);
  line-height: 1.15;
  letter-spacing: -0.01em;
  text-wrap: balance;
  margin: 0;
}
.k-label {
  font-size: var(--text-2xs);
  font-weight: 700;
  letter-spacing: var(--track-label);
  text-transform: uppercase;
  color: var(--ink-3);
  margin: 0;
}
.k-muted { color: var(--ink-2); font-size: var(--text-sm); margin: 0; }
.k-readout {
  font-size: var(--text-xs);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--ink-2);
  letter-spacing: 0.02em;
}

/* Seal (logo mark). Use the SVG symbol #k-seal inside. */
.k-seal { width: 22px; height: 22px; flex: none; display: block; }

/* Trim marks: four printer's corners instead of a border */
.k-trim {
  --tm: 12px;            /* arm length */
  --tw: 1.5px;           /* line weight */
  --tc: var(--ink-3);    /* line color */
  background:
    linear-gradient(var(--tc), var(--tc)) left top / var(--tm) var(--tw) no-repeat,
    linear-gradient(var(--tc), var(--tc)) left top / var(--tw) var(--tm) no-repeat,
    linear-gradient(var(--tc), var(--tc)) right top / var(--tm) var(--tw) no-repeat,
    linear-gradient(var(--tc), var(--tc)) right top / var(--tw) var(--tm) no-repeat,
    linear-gradient(var(--tc), var(--tc)) left bottom / var(--tm) var(--tw) no-repeat,
    linear-gradient(var(--tc), var(--tc)) left bottom / var(--tw) var(--tm) no-repeat,
    linear-gradient(var(--tc), var(--tc)) right bottom / var(--tm) var(--tw) no-repeat,
    linear-gradient(var(--tc), var(--tc)) right bottom / var(--tw) var(--tm) no-repeat;
}

/* Buttons */
.k-btn {
  appearance: none;
  border: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  min-height: 48px;
  padding: 0 var(--s5);
  border-radius: var(--r-md);
  font: 600 var(--text-md)/1 var(--font-ui);
  background: var(--ink);
  color: var(--on-ink);
  cursor: pointer;
  transition: transform var(--t-fast) var(--ease), opacity var(--t-fast) var(--ease);
}
.k-btn:active { transform: scale(0.98); opacity: 0.9; }
.k-btn:disabled { opacity: 0.5; pointer-events: none; }
.k-btn:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.k-btn .k-icon { width: 20px; height: 20px; }
.k-btn--block { width: 100%; }
.k-btn--quiet {
  background: transparent;
  color: var(--ink);
  box-shadow: inset 0 0 0 var(--hair) var(--line);
}
/* Only for dismiss-type actions (Reset, Cancel, Back). Anything the user must find is .k-btn--quiet, a filled .k-btn or .k-cta (SKILL.md rule 11). */
.k-btn--text {
  background: transparent;
  color: var(--ink-2);
  min-height: var(--tap);
  padding: 0 var(--s2);
  font-size: var(--text-sm);
}

/* Pill for Pro status in headers */
.k-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 var(--s3);
  border: 0;
  border-radius: 999px;
  font: 700 var(--text-2xs)/1 var(--font-ui);
  letter-spacing: var(--track-label);
  text-transform: uppercase;
  color: var(--ink);
  box-shadow: inset 0 0 0 var(--hair) var(--line);
  background: var(--card);
}

/* Chips: one choice from a short list (aspect ratios, percents) */
.k-chips { display: flex; gap: var(--s2); overflow-x: auto; scrollbar-width: none; }
.k-chip {
  flex: none;
  height: 34px;
  padding: 0 var(--s3);
  border: 0;
  border-radius: var(--r-sm);
  font: 600 var(--text-sm)/1 var(--font-ui);
  color: var(--ink-2);
  background: transparent;
  box-shadow: inset 0 0 0 var(--hair) var(--line);
  font-variant-numeric: tabular-nums;
}
.k-chip[aria-pressed="true"] { background: var(--ink); color: var(--on-ink); box-shadow: none; }

/* Segmented control: two or three modes */
.k-seg {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  padding: 3px;
  border-radius: 10px;
  background: var(--well);
}
.k-seg button {
  border: 0;
  height: 32px;
  border-radius: 8px;
  font: 600 var(--text-sm)/1 var(--font-ui);
  color: var(--ink-2);
  background: transparent;
}
.k-seg button[aria-pressed="true"] {
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}

/* Number input. 16px text stops iOS from zooming in on focus. */
.k-input {
  width: 100%;
  height: 40px;
  padding: 0 var(--s3);
  border: 0;
  border-radius: var(--r-sm);
  background: var(--well);
  color: var(--ink);
  font: 600 16px/1 var(--font-ui);
  font-variant-numeric: tabular-nums;
}
.k-input:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; }

/* Slider: hairline track, ink fill, square thumb */
.k-slider { display: grid; gap: var(--s2); }
.k-slider__head { display: flex; justify-content: space-between; align-items: baseline; }
.k-slider__name { font-weight: 600; font-size: var(--text-sm); }
.k-range {
  --val: 50%;
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 28px;
  margin: 0;
  background:
    linear-gradient(var(--ink), var(--ink)) left center / var(--val) 2px no-repeat,
    linear-gradient(var(--line), var(--line)) left center / 100% 2px no-repeat;
}
.k-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: var(--r-seal);
  background: var(--ink);
  border: 3px solid var(--card);
  box-shadow: 0 0 0 var(--hair) var(--ink);
}
.k-range::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: var(--r-seal);
  background: var(--ink);
  border: 3px solid var(--card);
  box-shadow: 0 0 0 var(--hair) var(--ink);
}

/* Tool bar: labeled icons, active tool gets a tiny seal under it */
.k-toolbar {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 2px;
  padding: var(--s2) var(--s2) var(--s1);
}
.k-toolbar__sep { width: var(--hair); background: var(--line); margin: 6px 2px 14px; }
.k-tool {
  flex: 1 1 0;
  min-width: 0;
  display: grid;
  justify-items: center;
  gap: 5px;
  padding: 6px 0 10px;
  border: 0;
  background: transparent;
  color: var(--ink-3);
  font: 600 var(--text-2xs)/1 var(--font-ui);
  position: relative;
}
.k-tool .k-icon { color: var(--ink-2); }
.k-tool[aria-pressed="true"] { color: var(--ink); font-weight: 800; }
.k-tool[aria-pressed="true"] .k-icon { color: var(--ink); stroke-width: 2; }
.k-tool[aria-pressed="true"]::after {
  content: "";
  position: absolute;
  bottom: 0;
  width: 5px;
  height: 5px;
  border-radius: 1px;
  background: var(--seal);
}

/* Home tiles: tool shortcuts framed by trim marks */
.k-tiles { display: grid; gap: var(--s2); }
.k-tiles--4 { grid-template-columns: repeat(4, 1fr); }
.k-tiles--3 { grid-template-columns: repeat(3, 1fr); }
.k-tile {
  border: 0;
  color: var(--ink);
  display: grid;
  justify-items: center;
  align-content: center;
  gap: var(--s2);
  min-height: 78px;
  padding: var(--s3) var(--s1);
  font: 600 var(--text-xs)/1.2 var(--font-ui);
  text-align: center;
  border-radius: 2px;
  transition: background-color var(--t-fast) var(--ease);
}
.k-tile:active { background-color: var(--well); }

/* Bottom sheet */
.k-sheet {
  background: var(--card);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  padding: var(--s2) var(--s4) var(--s4);
  display: grid;
  gap: var(--s4);
  box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.12);
}
.k-sheet__handle { width: 36px; height: 4px; border-radius: 2px; background: var(--line); justify-self: center; }
.k-sheet__title { font: 700 var(--text-lg)/1.2 var(--font-ui); margin: 0; }

/* Toast */
.k-toast {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s3) var(--s4);
  border-radius: var(--r-md);
  background: var(--ink);
  color: var(--on-ink);
  font-size: var(--text-sm);
  font-weight: 500;
}
.k-toast .k-icon { width: 18px; height: 18px; }

/* Pro offer: the one paid moment. Seal red in both themes (white text passes AA),
   a Telegram Stars price pill, and a slow shine. Use once per screen at most. */
.k-cta {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: var(--s3);
  width: 100%;
  padding: 14px 14px 14px 16px;
  border: 0;
  border-radius: 14px;
  background: #C8381E;
  color: #FFFFFF;
  text-align: left;
  font-family: var(--font-ui);
  box-shadow: 0 12px 26px -14px rgba(200, 56, 30, 0.8);
  transition: transform var(--t-fast) var(--ease);
}
.k-cta:active { transform: scale(0.98); }
.k-cta:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.k-cta b { display: block; font-size: var(--text-md); font-weight: 800; letter-spacing: -0.005em; }
.k-cta small { display: block; margin-top: 2px; font-size: var(--text-xs); font-weight: 500; }
.k-cta__price {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 11px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  font: 800 var(--text-sm)/1 var(--font-ui);
  font-variant-numeric: tabular-nums;
}
.k-cta__price svg { width: 15px; height: 15px; fill: #FFC93C; stroke: none; } /* Telegram Stars gold */
.k-cta::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, 0.32) 50%, transparent 65%);
  transform: translateX(-100%);
  animation: k-shine 3.6s var(--ease) infinite;
}
@keyframes k-shine {
  0%, 55% { transform: translateX(-100%); }
  85%, 100% { transform: translateX(100%); }
}

/* Success stamp: the one orchestrated motion moment */
@keyframes k-stamp {
  0% { transform: scale(1.35) rotate(-8deg); opacity: 0; }
  60% { transform: scale(0.94) rotate(-3deg); opacity: 1; }
  100% { transform: scale(1) rotate(-3deg); opacity: 1; }
}
.k-stamp { animation: k-stamp 420ms var(--ease) both; transform: rotate(-3deg); }

@media (prefers-reduced-motion: reduce) {
  .k-stamp { animation: none; }
  .k-cta::after { animation: none; display: none; }
  .k-btn, .k-tile { transition: none; }
}
