/* Tile studio. Loads after /backstage/backstage.css, which gives the header, tabs,
   cards, buttons, inputs and colors; everything here is the studio's own and is
   prefixed st- (or mj- for a mahjong tile) so it never collides with Backstage. */

.st textarea, .st input[type="text"], .st input:not([type]), .st select { font-size: 16px; width: 100%; }
.st [hidden] { display: none !important; }
.st .muted { color: var(--ink-soft); }
.st .fine { font-size: 12.5px; color: var(--ink-faint); line-height: 1.45; margin: 6px 0 0; }
.st .sub { color: var(--ink-soft); font-size: 13.5px; margin: 0 0 12px; }
.st h3 { font: 600 15px/1.3 var(--sans); margin: 16px 0 8px; color: var(--ink); }

/* notes, inline only */
.st-note { border-radius: 12px; padding: 10px 12px; font-size: 13.5px; line-height: 1.45; margin: 10px 0 0; }
.st-note.good { background: var(--jade-soft); color: var(--jade-ink); }
.st-note.warn { background: var(--crak-soft); color: #8f1a15; }
.st-note.plain { background: var(--gold-soft); color: #6b4f12; }
.st-note b { font-weight: 700; }

.st-pill { font-size: 11.5px; font-weight: 700; padding: 4px 9px; border-radius: 999px; white-space: nowrap; }
.st-pill.new { background: var(--crak-soft); color: #8f1a15; }
.st-pill.making { background: var(--gold-soft); color: #6b4f12; }
.st-pill.sent { background: var(--jade-soft); color: var(--jade-ink); }
.st-pill.draft { background: var(--line-soft); color: var(--ink-soft); }

/* ---------- home ---------- */

.st-home { display: grid; gap: 14px; }
@media (min-width: 960px) {
  .st-home { grid-template-columns: 1.35fr 1fr; align-items: start; }
  .st-home .st-wide { grid-column: 1 / -1; }
}
.st-create { background: linear-gradient(160deg, #ffffff 0%, #fbf8f1 100%); }
.st-create h2 { font-size: 22px; }
.st-create textarea { min-height: 110px; margin-top: 4px; }
.st-ideas { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 2px; align-items: center; }
.st-ideas span { font-size: 12.5px; color: var(--ink-faint); margin-right: 2px; }
.st-chip {
  appearance: none; border: 1px solid var(--line); background: var(--paper); color: var(--ink-soft); border-radius: 999px;
  font: 600 13px/1 var(--sans); padding: 8px 12px; cursor: pointer;
}
.st-chip:hover { border-color: var(--jade); color: var(--jade-deep); }
.st-chip[aria-pressed="true"] { background: var(--jade-soft); border-color: var(--jade); color: var(--jade-ink); }
.st-makes { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 12px 0; padding: 10px 12px; border-radius: 12px; background: var(--line-soft); font-size: 13.5px; color: var(--ink-soft); }
.st-makes b { color: var(--ink); font-weight: 600; }
.st-linkbtn { appearance: none; border: 0; background: none; padding: 4px 0; font: 600 13.5px var(--sans); color: var(--jade-deep); cursor: pointer; white-space: nowrap; }

.st-list { display: grid; gap: 8px; }
.st-row {
  display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 14px; border: 1px solid var(--line-soft);
  background: var(--paper); text-decoration: none; color: var(--ink);
}
.st-row:hover { border-color: var(--line); }
.st-row .thumb { width: 42px; height: 56px; border-radius: 9px; background: var(--line-soft) center / cover; flex: none; }
.st-row .grow { flex: 1; min-width: 0; }
.st-row b { display: block; font-weight: 600; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.st-row small { display: block; color: var(--ink-faint); font-size: 12.5px; }
.st-sets { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.st-setcard { display: grid; gap: 8px; text-decoration: none; color: var(--ink); border: 1px solid var(--line-soft); background: var(--paper); border-radius: 16px; padding: 12px; }
.st-setcard:hover { border-color: var(--line); }
.st-setcard .tiles { display: flex; gap: 4px; min-height: 60px; align-items: flex-end; }
.st-setcard b { font-size: 14px; font-weight: 600; line-height: 1.3; }
.st-setcard small { color: var(--ink-faint); font-size: 12px; }

/* ---------- a request ---------- */

.st-back { display: inline-flex; align-items: center; gap: 4px; font-size: 14px; font-weight: 600; text-decoration: none; color: var(--jade-deep); margin: 0 0 6px; }
.st-quote { white-space: pre-wrap; background: var(--line-soft); border-radius: 12px; padding: 12px 14px; margin: 0; font-size: 15px; }
.st-photos { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 720px) { .st-photos { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.st-photo { margin: 0; }
.st-photo img { display: block; width: 100%; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 12px; border: 1px solid var(--line); background: var(--line-soft); }
.st-photo figcaption { font-size: 12.5px; color: var(--ink-soft); margin-top: 6px; line-height: 1.4; }
.st-photo figcaption b { display: block; color: var(--ink); font-size: 13px; }
.st-photo .flagged { color: #8f1a15; font-weight: 600; display: block; }

/* ---------- a set ---------- */

.st-sethead { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin-bottom: 4px; }
.st-title {
  flex: 1 1 260px; font: 600 26px/1.2 var(--display) !important; color: var(--ink); border: 0 !important; background: transparent !important;
  padding: 2px 0 !important; resize: none; overflow: hidden; min-height: 0 !important; box-shadow: none !important; border-radius: 0 !important;
  border-bottom: 1.5px dashed transparent !important;
}
.st-title:hover, .st-title:focus { border-bottom-color: var(--line) !important; }
.st-forchip { display: inline-flex; align-items: center; font-size: 12.5px; font-weight: 600; text-decoration: none; background: var(--jade-soft); color: var(--jade-ink); padding: 6px 10px; border-radius: 999px; }

.st-progress { display: flex; align-items: center; gap: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px 14px; margin: 10px 0 0; box-shadow: var(--shadow); }
.st-progress .bar { flex: 1; height: 8px; background: var(--line-soft); border-radius: 999px; overflow: hidden; }
.st-progress .bar span { display: block; height: 100%; background: var(--jade); border-radius: 999px; transition: width 0.4s ease; }
.st-progress b { font-size: 13.5px; white-space: nowrap; }

.st-steps {
  position: sticky; top: 52px; z-index: 4; display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; padding: 4px;
  margin: 12px 0 14px; background: rgba(244, 239, 228, 0.94); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--line); border-radius: 14px;
}
.st-steps a { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 4px; border-radius: 10px; text-decoration: none; color: var(--ink-soft); font: 600 14px var(--sans); }
.st-steps a .n { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--line-soft); font-size: 11.5px; color: var(--ink-soft); }
.st-steps a[aria-current="page"] { background: var(--jade-deep); color: #fff; }
.st-steps a[aria-current="page"] .n { background: rgba(255, 255, 255, 0.2); color: #fff; }
@media (max-width: 380px) { .st-steps a .n { display: none; } }

.st-grid2 { display: grid; gap: 14px; }
@media (min-width: 960px) { .st-grid2 { grid-template-columns: 1fr 1fr; align-items: start; } }

.st-refs { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.st-ref { position: relative; width: 64px; height: 64px; flex: none; border-radius: 12px; border: 1px solid var(--line); background: var(--line-soft); }
.st-ref img { width: 100%; height: 100%; object-fit: cover; border-radius: 11px; display: block; }
.st-ref.add { border: 1.5px dashed rgba(31, 111, 92, 0.45); background: var(--paper); color: var(--jade-deep); display: grid; place-items: center; cursor: pointer; }
.st-ref.small { width: 46px; height: 46px; }
.st-ref .x { position: absolute; top: -7px; right: -7px; width: 24px; height: 24px; border-radius: 50%; border: 0; background: var(--ink); color: #fff; display: grid; place-items: center; cursor: pointer; }

.st-counts { display: grid; gap: 2px; }
.st-count { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line-soft); }
.st-count:last-child { border-bottom: 0; }
.st-count .what { flex: 1; min-width: 0; }
.st-count .what b { display: block; font-size: 14.5px; }
.st-count .what small { display: block; font-size: 12.5px; color: var(--ink-faint); }
.st-stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--paper); }
.st-stepper button { appearance: none; border: 0; background: transparent; width: 40px; height: 38px; font: 600 18px var(--sans); color: var(--jade-deep); cursor: pointer; }
.st-stepper button:disabled { color: var(--line); cursor: default; }
.st-stepper span { min-width: 26px; text-align: center; font: 700 15px var(--sans); font-variant-numeric: tabular-nums; }
.st-switch { position: relative; width: 50px; height: 30px; border-radius: 999px; border: 0; background: var(--line); cursor: pointer; flex: none; transition: background 0.15s ease; }
.st-switch span { position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(30, 34, 41, 0.25); transition: transform 0.18s ease; }
.st-switch[aria-checked="true"] { background: var(--jade); }
.st-switch[aria-checked="true"] span { transform: translateX(20px); }
.st-seg { display: inline-flex; background: var(--line-soft); border-radius: 12px; padding: 3px; gap: 3px; }
.st-seg button { appearance: none; border: 0; background: transparent; border-radius: 9px; padding: 8px 10px; font: 600 13px var(--sans); color: var(--ink-soft); cursor: pointer; }
.st-seg button[aria-pressed="true"] { background: var(--card); color: var(--jade-deep); box-shadow: 0 1px 3px rgba(30, 34, 41, 0.12); }

.st-more summary { cursor: pointer; font-weight: 600; font-size: 14px; color: var(--jade-deep); list-style: none; padding: 6px 0; }
.st-more summary::-webkit-details-marker { display: none; }
.st-engines { display: grid; gap: 8px; margin: 8px 0 12px; }
.st-engine { text-align: left; border: 1px solid var(--line); background: var(--paper); border-radius: 12px; padding: 9px 12px; cursor: pointer; display: grid; gap: 2px; font: inherit; }
.st-engine b { font-size: 14px; }
.st-engine span { font-size: 12.5px; color: var(--ink-faint); }
.st-engine[aria-pressed="true"] { border-color: var(--jade); background: var(--jade-soft); }
.st-row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.st-action { padding: 16px 0 calc(8px + env(safe-area-inset-bottom, 0px)); }

/* pick */
.st-tiles { display: grid; gap: 14px; }
@media (min-width: 960px) { .st-tiles { grid-template-columns: 1fr 1fr; align-items: start; } }
.st-tile .st-row-between h2 { margin: 0; font-size: 17px; }
.st-state { font-size: 12.5px; color: var(--ink-faint); }
.st-opts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 12px 0 4px; }
@media (min-width: 600px) { .st-opts { grid-template-columns: repeat(auto-fill, minmax(96px, 116px)); } }
.st-opt { position: relative; display: grid; gap: 4px; justify-items: center; align-content: start; }
.st-opt button.pick { appearance: none; border: 0; background: transparent; padding: 4px; border-radius: 14px; cursor: pointer; width: 100%; line-height: 0; }
.st-opt button.pick:hover { background: var(--line-soft); }
.st-opt button.pick[aria-pressed="true"] { box-shadow: 0 0 0 2.5px var(--jade); background: var(--jade-soft); }
.st-opt .tick { position: absolute; top: -4px; right: -4px; width: 24px; height: 24px; border-radius: 50%; background: var(--jade); color: #fff; display: grid; place-items: center; pointer-events: none; }
.st-opt small { font-size: 11.5px; line-height: 1.25; text-align: center; color: var(--ink-faint); }
.st-opt .ip { font-weight: 700; }
.st-opt .ip.clear { color: #8f1a15; }
.st-opt .ip.slight { color: #8a5a12; }
.st-ph { width: 100%; aspect-ratio: 3 / 4; border-radius: 10px; background: linear-gradient(100deg, var(--line-soft) 30%, #fbf7ef 50%, var(--line-soft) 70%); background-size: 200% 100%; animation: st-shimmer 1.4s ease-in-out infinite; }
.st-ph.off { animation: none; background: var(--crak-soft); }
@keyframes st-shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
@media (prefers-reduced-motion: reduce) { .st-ph { animation: none; } }
.st-toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.st-panel { margin-top: 10px; padding: 12px; border-radius: 12px; background: var(--line-soft); }
.st-panel textarea { min-height: 72px; background: var(--card); }
.st-panel .st-row-between { margin-top: 8px; }

/* colors */
.st-colors { display: flex; flex-wrap: wrap; gap: 14px; }
.st-color { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; color: var(--ink-soft); cursor: pointer; grid-auto-flow: column; }
.st-color input { width: 44px !important; height: 44px; padding: 3px !important; border-radius: 12px; cursor: pointer; }
.st-presets { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 0; }
.st-preset { appearance: none; display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--paper); border-radius: 12px; padding: 7px 10px 7px 8px; font: 600 13px var(--sans); color: var(--ink-soft); cursor: pointer; }
.st-preset i { display: inline-flex; gap: 2px; }
.st-preset i b { width: 10px; height: 18px; border-radius: 3px; display: block; }
.st-preset:hover { border-color: var(--jade); }
.st-faces { display: flex; flex-wrap: wrap; gap: 8px; }
.st-face { appearance: none; display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line); background: var(--paper); border-radius: 12px; min-height: 40px; padding: 0 11px 0 7px; font: 600 13.5px var(--sans); color: var(--ink-soft); cursor: pointer; }
.st-face span { width: 22px; height: 28px; border-radius: 6px; border: 1px solid; flex: none; }
.st-face[aria-pressed="true"] { border-color: var(--jade); color: var(--jade-ink); background: var(--jade-soft); }
.st-sample { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; padding: 12px; background: var(--line-soft); border-radius: 14px; margin-top: 14px; }
.st-swatches { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.st-swatch { appearance: none; width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--card); box-shadow: 0 0 0 1px var(--line); cursor: pointer; padding: 0; }
.st-swatch[aria-pressed="true"] { box-shadow: 0 0 0 2.5px var(--jade); }
.st-backmaker { display: grid; grid-template-columns: auto 1fr; gap: 14px; align-items: center; margin-top: 12px; }

/* send */
.st-checks { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.st-checks li { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; line-height: 1.4; }
.st-checks .dot { flex: none; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; margin-top: 1px; }
.st-checks .ok .dot { background: var(--jade-soft); color: var(--jade-deep); }
.st-checks .warn .dot { background: var(--gold-soft); color: #8a5a12; }
.st-checks .bad .dot { background: var(--crak-soft); color: #8f1a15; }

/* the game preview */
.st-phone { border-radius: 28px; border: 8px solid #1e2229; background: #f7f2e9 center / cover no-repeat; overflow: hidden; box-shadow: 0 10px 24px rgba(30, 34, 41, 0.14); max-width: 360px; margin: 0 auto; }
.st-phone-in { padding: 12px 10px 14px; display: flex; flex-direction: column; gap: 8px; }
.st-phone .panel { background: rgba(255, 253, 248, 0.94); border: 1px solid #e4dccb; border-radius: 14px; padding: 8px 9px; }
.st-phone .lbl { font-size: 10.5px; font-weight: 700; color: #5e6873; margin-bottom: 4px; display: flex; justify-content: space-between; }
.st-phone .opp { display: flex; align-items: center; gap: 6px; }
.st-phone .opp + .opp { margin-top: 4px; }
.st-phone .seat { width: 34px; font-size: 10.5px; font-weight: 700; color: #4b525c; }
.st-phone .row { display: flex; gap: 1.5px; flex-wrap: wrap; }
.st-tray { background: linear-gradient(180deg, #e7dcc4, #dccfb2); border-radius: 12px; padding: 7px 6px 8px; box-shadow: inset 0 2px 5px rgba(58, 47, 28, 0.18); }
.st-rack { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; }
.st-rack + .st-rack { margin-top: 5px; }
.st-rack .mj { width: 100% !important; height: auto !important; aspect-ratio: 3 / 4; }

/* a mahjong tile */
.mj { display: inline-block; flex: none; line-height: 0; }
.mj svg { width: 100%; height: 100%; display: block; overflow: visible; }
.mj-table { border-radius: 8px; background: var(--line-soft) center / cover no-repeat; box-shadow: inset 0 0 0 1px var(--line); }
.st-opt .mj { width: 100% !important; height: auto !important; aspect-ratio: 3 / 4; }

/* the bigger view */
dialog.st-viewer { border: 0; padding: 0; width: min(560px, 100%); max-height: 92vh; border-radius: 22px; background: var(--card); color: var(--ink); box-shadow: 0 -10px 40px rgba(30, 34, 41, 0.25); }
dialog.st-viewer::backdrop { background: rgba(30, 34, 41, 0.5); }
@media (max-width: 600px) { dialog.st-viewer { margin: auto auto 0; border-radius: 22px 22px 0 0; } }
.st-viewer-in { padding: 16px 16px calc(18px + env(safe-area-inset-bottom, 0px)); overflow: auto; max-height: 92vh; }
.st-viewer-in .art { display: grid; grid-template-columns: 1fr 110px; gap: 14px; align-items: center; margin-top: 10px; }
.st-viewer-in .art img { width: 100%; border-radius: 14px; border: 1px solid var(--line); background: var(--line-soft); display: block; }
.st-viewer-in pre { white-space: pre-wrap; font: 13px/1.5 var(--sans); background: var(--line-soft); padding: 10px 12px; border-radius: 12px; margin: 8px 0 0; color: var(--ink-soft); }

/* about */
.st-about ol, .st-about ul { padding-left: 20px; margin: 0 0 6px; }
.st-about li { margin-bottom: 6px; line-height: 1.5; }
.st-about table { width: 100%; border-collapse: collapse; font-size: 14px; margin: 6px 0 4px; }
.st-about td, .st-about th { text-align: left; padding: 7px 6px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.st-about th { font-size: 12px; color: var(--ink-faint); font-weight: 700; }
.st-about td.n { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }

.st-choices { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 12px; }
.st-signin { text-align: center; padding: 32px 18px; max-width: 460px; margin: 40px auto; }
.st .spinner.sm { width: 14px; height: 14px; border-width: 2px; display: inline-block; vertical-align: -2px; }
.st .btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.st .btn.primary .spinner { border-color: rgba(255, 255, 255, 0.35); border-top-color: #fff; }
