:root {
  --paper: #f7f3ec;
  --paper-deep: #efe7db;
  --paper-strong: #fbf8f3;
  --ink: #1e1914;
  --ink-soft: rgba(30, 25, 20, 0.72);
  --ink-faint: rgba(30, 25, 20, 0.46);
  --line: rgba(30, 25, 20, 0.1);
  --line-strong: rgba(30, 25, 20, 0.16);
  --accent: #c97953;
  --accent-warm: #a85c3a;
  --success: #4f715a;
  --danger: #a0533d;
  --surface: rgba(255, 252, 247, 0.76);
  --surface-strong: rgba(255, 253, 249, 0.9);
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-serif: "Spectral", "Noto Serif SC", "Songti SC", "STSong", serif;
  --transition: 180ms ease;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--font-sans);
  line-height: 1.5;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  border: 0;
  outline: 0;
  background: none;
  color: inherit;
  font: inherit;
}

button {
  cursor: pointer;
}

:is(a, button, input, select, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

::selection {
  background: rgba(201, 121, 83, 0.22);
}

#nav {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px clamp(22px, 4vw, 52px);
  background: var(--paper);
  border-bottom: 1px solid rgba(30, 25, 20, 0.08);
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-weight: 650;
  font-size: 1.02rem;
  letter-spacing: 0;
}

.logo img {
  display: block;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  object-fit: cover;
}

main {
  position: relative;
  z-index: 1;
}

section {
  padding-inline: clamp(22px, 4vw, 52px);
}

#hero {
  min-height: calc(100vh - 76px);
  display: flex;
  align-items: center;
  padding-top: 24px;
  padding-bottom: 44px;
}

.hero-grid {
  width: min(1360px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 640px);
  justify-content: center;
  row-gap: clamp(28px, 5vh, 48px);
}

.hero-copy {
  max-width: 46rem;
  text-align: center;
}

.hero-kicker {
  margin-bottom: 14px;
  color: var(--ink-faint);
  font-size: 0.74rem;
  letter-spacing: 0.16em;
}

#hero h1 {
  font-family: var(--font-serif);
  font-size: clamp(2.4rem, 5vw, 3.8rem);
  line-height: 1.08;
  letter-spacing: 0;
  font-weight: 600;
  color: var(--ink);
}

.hero-side {
  width: 100%;
  padding: 24px 28px 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--paper-strong);
}

.badge {
  display: inline-flex;
  align-items: center;
  margin-bottom: 14px;
  padding: 8px 12px;
  border: 1px solid rgba(30, 25, 20, 0.1);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.42);
  color: rgba(30, 25, 20, 0.76);
  font-size: 0.84rem;
  font-weight: 600;
}

.subtitle {
  max-width: 30rem;
  margin-top: 0;
  color: rgba(30, 25, 20, 0.62);
  font-size: 0.94rem;
  line-height: 1.76;
}

.url-input-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  margin-top: 32px;
  padding: 8px;
  border: 1px solid rgba(30, 25, 20, 0.12);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.5);
}

#url-input {
  min-width: 0;
  width: 100%;
  padding: 16px 18px;
  border-radius: 10px;
  background: rgba(248, 243, 236, 0.84);
  color: var(--ink);
  font-size: 0.98rem;
}

#url-input::placeholder {
  color: rgba(30, 25, 20, 0.38);
}

#distill-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 0 22px;
  border-radius: 10px;
  background: var(--ink);
  color: #fffaf4;
  font-weight: 650;
  transition: background var(--transition);
}

#distill-btn:hover {
  background: #2e2620;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid rgba(30, 25, 20, 0.08);
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat strong {
  font-family: var(--font-serif);
  font-size: clamp(1.4rem, 2vw, 1.8rem);
  font-weight: 600;
  line-height: 1;
}

.stat span {
  color: rgba(30, 25, 20, 0.5);
  font-size: 0.8rem;
  line-height: 1.45;
}

#workspace {
  width: min(1320px, 100%);
  margin: 0 auto 88px;
  padding-top: 8px;
  padding-bottom: 40px;
  /* Sticky nav (~70px) would otherwise cover the panel head on auto-scroll. */
  scroll-margin-top: 84px;
}

#history-section {
  width: min(1320px, 100%);
  margin: 0 auto 84px;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 22px;
  /* Panels have very different heights (short analysis summary vs long
     config form). The grid default `stretch` forced the short panel to
     grow to the tall one's height, leaving a big blank slab that fills
     the viewport once the user scrolls down to the feature/advanced
     sections. `start` keeps each panel at its natural height. */
  align-items: start;
}

/* Short summary panel stays visible while the long config form scrolls. */
#analysis-panel {
  position: sticky;
  top: 88px;
}

.panel {
  overflow: hidden;
  border: 1px solid rgba(30, 25, 20, 0.08);
  border-radius: 16px;
  background: var(--paper-strong);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 22px 24px;
  border-bottom: 1px solid rgba(30, 25, 20, 0.08);
}

.panel-head h2 {
  font-family: var(--font-serif);
  font-size: 1.34rem;
  font-weight: 600;
  letter-spacing: 0;
}

.panel-body {
  padding: 24px;
}

.status-badge {
  padding: 6px 11px;
  border-radius: 6px;
  background: rgba(201, 121, 83, 0.14);
  color: #8a4b2d;
  font-size: 0.77rem;
  font-weight: 700;
}

.status-badge.done {
  background: rgba(79, 113, 90, 0.14);
  color: var(--success);
}

.analysis-loader {
  text-align: left;
  padding: 12px 0 6px;
}

.loader-bar {
  width: 100%;
  height: 2px;
  margin-bottom: 16px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(30, 25, 20, 0.07);
}

.loader-bar::after {
  content: "";
  display: block;
  width: 30%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(201, 121, 83, 0) 0%, rgba(201, 121, 83, 0.72) 50%, rgba(201, 121, 83, 0) 100%);
  animation: load-slide 1.5s ease infinite;
}

@keyframes load-slide {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(360%); }
}

#loader-text {
  color: var(--ink-soft);
  font-size: 0.92rem;
}

#config-panel .config-grid,
#config-panel .feature-grid,
#config-panel .advanced-grid {
  /* Full-width stacked rows read better than a 2-col split at this column
     width: the feature cards keep their copy on 1-2 lines instead of
     wrapping one phrase per line (see screenshot). */
  grid-template-columns: 1fr;
}

#config-panel .field,
#config-panel .field-full {
  grid-column: 1 / -1;
}

.analysis-results {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.analysis-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid rgba(30, 25, 20, 0.06);
}

.analysis-item:last-child {
  border-bottom: 0;
}

.analysis-item .label {
  flex-shrink: 0;
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.analysis-item .value {
  min-width: 0;
  overflow-wrap: anywhere;
  font-weight: 600;
  text-align: right;
}

.analysis-item .value.bad { color: var(--danger); }
.analysis-item .value.good { color: var(--success); }
.analysis-item .value.info { color: var(--accent-warm); }

.analysis-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 18px;
}

.config-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(200px, 240px);
  gap: 18px;
  margin-bottom: 24px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field span {
  color: var(--ink-faint);
  font-size: 0.86rem;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}

.field input[type="text"],
.field input[type="number"],
.field select,
.field textarea {
  min-height: 54px;
  width: 100%;
  padding: 14px 16px;
  border: 1px solid rgba(30, 25, 20, 0.1);
  border-radius: 10px;
  background: rgba(250, 246, 240, 0.94);
  font-size: 1rem;
  font-family: inherit;
  transition: border-color var(--transition), background var(--transition);
}

.field textarea {
  resize: vertical;
  line-height: 1.6;
}

.field input[type="text"]:focus,
.field input[type="number"]:focus,
.field select:focus,
.field textarea:focus,
.icon-upload-meta input[type="file"]:focus {
  border-color: rgba(201, 121, 83, 0.5);
  background: rgba(255, 252, 246, 1);
}

.field-full {
  grid-column: 1 / -1;
}

.field-note {
  color: rgba(30, 25, 20, 0.48);
  font-size: 0.82rem;
  line-height: 1.6;
}

.field-note-inline {
  margin-top: -2px;
}

.icon-upload {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.file-picker-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  min-height: 54px;
  padding: 10px 14px;
  border: 1px solid rgba(30, 25, 20, 0.1);
  border-radius: 10px;
  background: rgba(250, 246, 240, 0.94);
}

.file-picker-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid rgba(30, 25, 20, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--transition);
}

.file-picker-btn:hover {
  background: rgba(255, 255, 255, 1);
}

.file-picker-name {
  min-width: 0;
  overflow: hidden;
  color: rgba(30, 25, 20, 0.56);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.88rem;
}

.icon-upload-preview {
  position: relative;
  width: 96px;
  height: 96px;
  border-radius: 14px;
  overflow: hidden;
  background: rgba(250, 246, 240, 0.96);
  border: 1px solid rgba(30, 25, 20, 0.1);
}

.icon-upload-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}

.icon-upload-preview.has-image img {
  display: block;
}

.icon-upload-preview span {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  color: rgba(30, 25, 20, 0.42);
  font-size: 0.8rem;
  text-align: center;
  line-height: 1.35;
}

.icon-upload-preview.has-image span {
  display: none;
}

.icon-upload-meta {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.icon-upload-clear {
  align-self: flex-start;
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid rgba(30, 25, 20, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.42);
  color: var(--ink-soft);
  font-size: 0.85rem;
  font-weight: 600;
  transition: background var(--transition);
}

.icon-upload-clear:hover {
  background: rgba(255, 255, 255, 0.74);
}

.icon-upload-clear:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  transform: none;
  background: rgba(255, 255, 255, 0.28);
}

.advanced-panel {
  margin-bottom: 24px;
  border: 1px solid rgba(30, 25, 20, 0.08);
  border-radius: 12px;
  background: rgba(251, 248, 243, 0.68);
}

.feature-panel {
  margin-bottom: 18px;
  border: 1px solid rgba(30, 25, 20, 0.08);
  border-radius: 12px;
  background: rgba(252, 249, 244, 0.8);
}

/* NOTE: .feature-panel is currently unused (platform tabs replaced it) but
   its summary sub-rules below are shared with .advanced-panel, which the
   Android tab still uses — so the container stays until the last details
   block migrates. */

.feature-panel summary,
.advanced-panel summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 18px;
  cursor: pointer;
  list-style: none;
}

/* Stacked override: the Android tab column (~430px) cannot fit title +
   a nowrap sub like "Android version and package name" side by side —
   it blew the summary (and the page) out horizontally. */
.advanced-panel summary {
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.feature-panel summary::-webkit-details-marker,
.advanced-panel summary::-webkit-details-marker {
  display: none;
}

.feature-panel summary span,
.advanced-panel summary span {
  color: var(--ink);
  font-size: 1rem;
  font-weight: 700;
}

.feature-panel summary small,
.advanced-panel summary small {
  color: rgba(30, 25, 20, 0.46);
  font-size: 0.84rem;
  text-align: right;
  white-space: nowrap;
}

.advanced-panel summary small {
  text-align: left;
  white-space: normal;
  line-height: 1.6;
}

.feature-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  padding: 0 18px 18px;
}

.feature-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 18px;
  border: 1px solid rgba(30, 25, 20, 0.08);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.46);
}

.feature-card-wide {
  grid-column: 1 / -1;
}

.feature-copy {
  min-width: 0;
}

.feature-copy p {
  margin: 10px 0 0;
  color: rgba(30, 25, 20, 0.58);
  font-size: 0.88rem;
  line-height: 1.65;
}

.feature-heading-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.feature-heading-row strong,
.permission-copy strong {
  color: var(--ink);
  font-size: 0.96rem;
  font-weight: 700;
}

.feature-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 6px;
  background: rgba(201, 121, 83, 0.12);
  color: var(--accent-warm);
  font-size: 0.73rem;
  font-weight: 700;
}

.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  cursor: pointer;
}

.switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch-ui {
  position: relative;
  display: inline-flex;
  width: 52px;
  height: 30px;
  border-radius: 999px;
  background: rgba(30, 25, 20, 0.18);
  transition: background var(--transition);
}

.switch-ui::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 8px rgba(30, 25, 20, 0.18);
  transition: transform var(--transition);
}

.switch input:checked + .switch-ui {
  background: rgba(201, 121, 83, 0.85);
}

.switch input:checked + .switch-ui::after {
  transform: translateX(22px);
}

.segmented-control {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
}

.segmented-control-compact {
  width: auto;
  min-width: 240px;
}

.segmented-option {
  display: flex;
  min-width: 0;
}

.segmented-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented-option span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  width: 100%;
  padding: 0 14px;
  border: 1px solid rgba(30, 25, 20, 0.1);
  border-radius: 8px;
  background: rgba(250, 246, 240, 0.94);
  color: rgba(30, 25, 20, 0.62);
  font-size: 0.88rem;
  font-weight: 600;
  text-align: center;
  transition: border-color var(--transition), background var(--transition), color var(--transition), transform var(--transition);
}

.segmented-option input:checked + span {
  border-color: rgba(201, 121, 83, 0.4);
  background: rgba(201, 121, 83, 0.12);
  color: var(--ink);
}

.permission-grid {
  display: grid;
  gap: 14px;
  width: 100%;
}

.permission-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding-top: 14px;
  border-top: 1px solid rgba(30, 25, 20, 0.07);
}

.permission-row:first-child {
  padding-top: 0;
  border-top: 0;
}

.permission-copy {
  min-width: 0;
}

.permission-copy small {
  display: block;
  margin-top: 6px;
  color: rgba(30, 25, 20, 0.52);
  font-size: 0.83rem;
  line-height: 1.55;
}

.advanced-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  padding: 0 18px 18px;
}

/* ===== Platform overview (left panel) ===== */
.platform-overview {
  padding: 22px 24px 24px;
  border-top: 1px solid rgba(30, 25, 20, 0.08);
}

.platform-overview h3 {
  font-family: var(--font-serif);
  font-size: 1.12rem;
  font-weight: 600;
}

.platform-overview-sub {
  margin-top: 6px;
  color: var(--ink-soft);
  font-size: 0.88rem;
  line-height: 1.65;
}

.platform-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
  list-style: none;
}

.platform-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid rgba(30, 25, 20, 0.07);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.42);
}

.platform-list li > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.platform-list strong {
  font-size: 0.9rem;
  font-weight: 700;
}

.platform-list span {
  color: rgba(30, 25, 20, 0.52);
  font-size: 0.8rem;
}

.p-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border-radius: 10px;
  border: 1px solid rgba(30, 25, 20, 0.08);
  background: rgba(255, 255, 255, 0.66);
}

.p-icon svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
  display: block;
}

.p-icon-outline svg {
  fill: none;
}

.p-icon-windows { color: #1889d6; }
.p-icon-apple { color: #181412; }
.p-icon-linux { color: #3f6b4c; }
.p-icon-android { color: #4f8f4b; }

/* ===== Platform tabs (right panel) ===== */
.platform-config {
  margin-bottom: 24px;
  border: 1px solid rgba(30, 25, 20, 0.08);
  border-radius: 12px;
  background: rgba(252, 249, 244, 0.8);
}

/* Stacked (not side-by-side): the sub-copy is too long in most languages to
   share one row inside a ~430px column — side-by-side squeezed the title
   into vertical one-character-per-line stacking. */
.platform-config-head {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 16px 18px 0;
}

.platform-config-head span {
  color: var(--ink);
  font-size: 1rem;
  font-weight: 700;
}

.platform-config-head small {
  color: rgba(30, 25, 20, 0.46);
  font-size: 0.84rem;
  line-height: 1.6;
}

/* Wrapped pills, not a scroller: five tabs physically cannot fit a ~394px
   row, so horizontal scrolling always hid the last tab (Linux) with zero
   affordance. Wrapping keeps every platform one tap away. */
.platform-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
  padding: 0 18px 12px;
}

.platform-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  min-height: 42px;
  padding: 0 16px 0 12px;
  border: 1px solid rgba(30, 25, 20, 0.1);
  border-radius: 8px;
  background: rgba(250, 246, 240, 0.94);
  color: rgba(30, 25, 20, 0.62);
  font-size: 0.88rem;
  font-weight: 600;
  transition: border-color var(--transition), background var(--transition), color var(--transition);
}

.platform-tab svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
  display: block;
  flex-shrink: 0;
}

/* Stroke-based glyphs (e.g. the Linux terminal icon) carry fill="none" as a
   presentation attribute — any CSS fill rule outranks it, so re-assert none
   here or the rect renders as a solid blob. */
.platform-tab svg[fill="none"] {
  fill: none;
}

.platform-tab:hover {
  color: var(--ink);
}

.platform-tab.active {
  border-color: rgba(201, 121, 83, 0.45);
  background: rgba(201, 121, 83, 0.13);
  color: var(--ink);
}

.platform-tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.platform-panels {
  padding: 0 18px 18px;
}

/* .feature-grid / .advanced-panel were designed as top-level config sections
   with their own outer spacing; nested inside a tab panel that spacing would
   double up (cards inset 36px while the advanced box sits at 18px). */
.platform-panels .feature-grid {
  padding: 0 0 14px;
}

.platform-panels .advanced-panel {
  margin-bottom: 0;
}

.platform-panel[hidden] {
  display: none;
}

/* Tab switches re-trigger this (display none -> block), giving a subtle
   fade-rise instead of a hard cut. Gated on no-preference so reduced-motion
   users get the instant switch. */
@media (prefers-reduced-motion: no-preference) {
  .platform-panel {
    animation: panel-in 160ms ease;
  }
  @keyframes panel-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

.platform-panel-intro {
  margin: 0 0 14px;
  color: rgba(30, 25, 20, 0.58);
  font-size: 0.88rem;
  line-height: 1.65;
}

.window-size-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 8px;
}

.platform-panels .feature-card {
  margin-top: 14px;
}

.platform-note {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px;
  border: 1px solid rgba(30, 25, 20, 0.08);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.46);
}

.platform-note strong {
  color: var(--ink);
  font-size: 0.96rem;
  font-weight: 700;
}

.platform-note p {
  margin: 0;
  color: rgba(30, 25, 20, 0.58);
  font-size: 0.88rem;
  line-height: 1.65;
}

.color-wrap {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 54px;
  flex-wrap: wrap;
}

.color-wrap input[type="color"] {
  width: 56px;
  height: 56px;
  flex-shrink: 0;
  border: 1px solid rgba(30, 25, 20, 0.12);
  border-radius: 10px;
  background: none;
}

#color-hex {
  color: var(--ink-soft);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.96rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.btn-primary {
  width: 100%;
  padding: 15px 16px;
  border-radius: 10px;
  background: var(--ink);
  color: #fffaf5;
  font-weight: 650;
  transition: background var(--transition);
}

.btn-primary:hover {
  background: #2e2620;
}

.create-note {
  display: block;
  margin-top: 10px;
  text-align: center;
}

.result-panel {
  margin: 28px auto 0;
  padding: 34px;
  text-align: left;
}

.history-shell {
  padding: 0;
}

.history-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 28px 30px 24px;
  border-bottom: 1px solid rgba(30, 25, 20, 0.08);
}

.history-kicker {
  color: var(--ink-faint);
  font-size: 0.74rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.history-head h2 {
  margin-top: 8px;
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 600;
}

.history-sub {
  max-width: 42rem;
  margin-top: 10px;
  color: var(--ink-soft);
  font-size: 0.95rem;
  line-height: 1.7;
}

.history-toolbar {
  display: inline-flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid rgba(30, 25, 20, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.5);
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 600;
  transition: background var(--transition);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.86);
}

.history-body {
  padding: 20px 30px 30px;
}

.history-empty {
  padding: 22px 0 4px;
  color: rgba(30, 25, 20, 0.48);
  font-size: 0.94rem;
  line-height: 1.7;
}

.history-empty p {
  margin: 0;
}

.history-toggle-btn {
  display: flex;
  justify-content: center;
  width: 100%;
  max-width: 240px;
  margin: 18px auto 0;
}

.history-list {
  display: flex;
  flex-direction: column;
}

.history-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  padding: 22px 0;
}

.history-card + .history-card {
  border-top: 1px solid var(--line);
}

.history-main {
  min-width: 0;
}

.history-name-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.history-icon {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 8px;
  border: 1px solid rgba(30, 25, 20, 0.08);
  background: rgba(255, 255, 255, 0.7);
  object-fit: cover;
}

.history-name-block {
  min-width: 0;
}

.history-name {
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.3;
}

.history-link {
  margin-top: 4px;
  overflow: hidden;
  color: rgba(30, 25, 20, 0.5);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8rem;
}

.history-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.history-breakdown {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.history-breakdown-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 5px 0;
  border-bottom: 1px solid rgba(30, 25, 20, 0.06);
  color: rgba(30, 25, 20, 0.58);
  font-size: 0.82rem;
}

.history-breakdown-row:last-child {
  border-bottom: 0;
}

.history-breakdown-row strong {
  color: var(--ink);
  font-size: 0.84rem;
  font-weight: 600;
  text-align: right;
}

.history-breakdown-row-wide {
  grid-column: 1 / -1;
}

.history-meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid rgba(30, 25, 20, 0.08);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.46);
  color: rgba(30, 25, 20, 0.62);
  font-size: 0.8rem;
  white-space: nowrap;
}

.history-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: stretch;
  justify-content: flex-start;
}

.history-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 126px;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid rgba(30, 25, 20, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.54);
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 600;
  text-decoration: none;
  transition: background var(--transition);
}

.history-action:hover {
  background: rgba(255, 255, 255, 0.9);
}

.history-action.primary {
  background: var(--ink);
  border-color: var(--ink);
  color: #fffaf5;
}

.history-action-danger {
  color: #9f4b42;
  background: rgba(186, 96, 81, 0.08);
}

.history-action-danger:hover {
  background: rgba(186, 96, 81, 0.14);
}

.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;
}

.result-panel h2 {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  letter-spacing: 0;
  font-weight: 600;
}

.result-sub {
  max-width: 42rem;
  margin-top: 8px;
  margin-bottom: 24px;
  color: var(--ink-soft);
  line-height: 1.72;
}

.result-link-wrap {
  display: flex;
  max-width: 820px;
  margin: 0 0 20px;
  overflow: hidden;
  border: 1px solid rgba(30, 25, 20, 0.1);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.5);
}

.result-link-wrap input {
  flex: 1;
  min-width: 0;
  padding: 15px 16px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.88rem;
}

#copy-btn {
  padding: 0 18px;
  background: var(--ink);
  color: #fffaf4;
  font-weight: 650;
}

.platforms {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
}

.platform-tag {
  padding: 7px 14px;
  border: 1px solid rgba(30, 25, 20, 0.08);
  border-radius: 6px;
  background: rgba(255, 252, 247, 0.56);
  color: var(--ink-soft);
  font-size: 0.82rem;
}

.preview-shell {
  overflow: hidden;
  border: 1px solid rgba(30, 25, 20, 0.08);
  border-radius: 14px;
  background: rgba(255, 252, 247, 0.92);
}

.preview-shell-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(30, 25, 20, 0.08);
  background: rgba(250, 246, 240, 0.9);
}

.preview-shell-chrome {
  display: flex;
  gap: 6px;
}

.preview-shell-chrome span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: rgba(30, 25, 20, 0.18);
}

.preview-shell-chrome span:nth-child(1) { background: #d8a085; }
.preview-shell-chrome span:nth-child(2) { background: #e4c09c; }
.preview-shell-chrome span:nth-child(3) { background: #a7b892; }

.preview-url {
  flex: 1;
  min-width: 0;
  padding: 10px 13px;
  overflow: hidden;
  border: 1px solid rgba(30, 25, 20, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.54);
  color: var(--ink-faint);
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8rem;
}

.preview-open-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  height: 40px;
  padding: 0 14px;
  border: 1px solid rgba(30, 25, 20, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.48);
  color: var(--ink);
  font-weight: 600;
  transition: background var(--transition);
}

.preview-open-btn:hover {
  background: rgba(255, 255, 255, 0.84);
}

.preview-frame-wrap {
  background: #fffdfa;
}

#preview-frame {
  display: block;
  width: 100%;
  height: min(72vh, 820px);
  border: 0;
  background: #fff;
}

[data-reveal] {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.55s ease, transform 0.55s ease;
}

[data-reveal].revealed {
  opacity: 1;
  transform: translateY(0);
}

.hidden {
  display: none !important;
}

@media (max-width: 1100px) {
  .workspace-grid {
    grid-template-columns: 1fr;
  }

  /* Stacked layout: sticky would cover content while scrolling. */
  #analysis-panel {
    position: static;
  }

  .config-grid,
  .feature-grid,
  .advanced-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .logo span {
    display: none;
  }
}

@media (max-width: 720px) {
  #nav {
    padding-inline: 14px;
    gap: 10px;
  }

  .nav-actions {
    gap: 6px;
  }

  .qq-group-btn {
    padding: 0 8px;
    font-size: 0.78rem;
  }

  #lang-select {
    max-width: 6.6rem;
  }

  #hero {
    min-height: auto;
    padding-top: 12px;
    padding-bottom: 36px;
  }

  .hero-side {
    padding: 22px 18px 20px;
  }

  #hero h1 {
    font-size: clamp(2rem, 9vw, 2.6rem);
  }

  .url-input-wrap {
    grid-template-columns: 1fr;
  }

  #distill-btn {
    justify-content: center;
    min-height: 54px;
  }

  .stats,
  .config-grid,
  .feature-grid,
  .advanced-grid,
  .window-size-grid {
    grid-template-columns: 1fr;
  }

  .icon-upload {
    grid-template-columns: 1fr;
  }

  .file-picker-row {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .file-picker-btn {
    width: 100%;
  }

  .file-picker-name {
    white-space: normal;
    line-height: 1.5;
  }

  .icon-upload-preview {
    width: 84px;
    height: 84px;
    border-radius: 12px;
  }

  .feature-panel summary {
    flex-direction: column;
    align-items: flex-start;
  }

  .feature-panel summary small {
    text-align: left;
  }

  .feature-card,
  .permission-row {
    flex-direction: column;
    align-items: stretch;
  }

  .segmented-control-compact {
    width: 100%;
    min-width: 0;
  }

  .color-wrap {
    align-items: center;
  }

  .panel-head,
  .panel-body,
  .result-panel {
    padding-left: 20px;
    padding-right: 20px;
  }

  .result-panel {
    padding-top: 28px;
    padding-bottom: 28px;
  }

  .result-link-wrap {
    flex-direction: column;
  }

  #copy-btn {
    min-height: 48px;
  }

  .preview-shell-head {
    flex-wrap: wrap;
  }

  .preview-url {
    order: 3;
    width: 100%;
  }

  .preview-open-btn span {
    display: none;
  }

  .history-head,
  .history-body {
    padding-left: 20px;
    padding-right: 20px;
  }

  .history-head {
    flex-direction: column;
  }

  .history-toolbar {
    width: 100%;
    justify-content: flex-start;
  }

  .history-card {
    grid-template-columns: 1fr;
  }

  .history-breakdown {
    grid-template-columns: 1fr;
  }

  .history-actions {
    flex-direction: row;
    flex-wrap: wrap;
  }
}

/* ===== Language switcher ===== */
.lang-switcher {
  display: inline-flex;
  align-items: center;
}

.nav-actions {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  flex: none;
}

.gh-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  color: var(--ink, #1e1914);
  border: 1px solid rgba(30, 25, 20, 0.16);
  background-color: rgba(255, 251, 246, 0.72);
  transition: border-color 0.18s ease, background-color 0.18s ease, color 0.18s ease;
}

.gh-link:hover {
  border-color: rgba(30, 25, 20, 0.32);
  color: var(--accent, #c97953);
}

.gh-link:focus-visible {
  outline: 2px solid var(--accent, #c97953);
  outline-offset: 2px;
}

.gh-link svg {
  display: block;
}

.qq-group {
  position: relative;
  display: inline-flex;
  align-self: stretch;
}

.qq-group-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  height: 40px;
  min-width: 44px;
  padding: 0 12px;
  white-space: nowrap;
  border-radius: 999px;
  border: 1px solid rgba(30, 25, 20, 0.16);
  background-color: rgba(255, 251, 246, 0.72);
  color: var(--ink, #1e1914);
  font-size: 0.86rem;
  font-weight: 650;
  letter-spacing: 0;
  transition: border-color 0.18s ease, background-color 0.18s ease, color 0.18s ease;
}

.qq-group-btn:hover,
.qq-group-btn[aria-expanded="true"] {
  border-color: rgba(30, 25, 20, 0.32);
  color: var(--accent, #c97953);
}

.qq-group-btn:focus-visible {
  outline: 2px solid var(--accent, #c97953);
  outline-offset: 2px;
}

.qq-group-panel {
  position: absolute;
  top: calc(100% + 10px);
  inset-inline-end: 0;
  z-index: 30;
  width: min(320px, calc(100vw - 28px));
  padding: 16px 16px 14px;
  border-radius: 14px;
  border: 1px solid rgba(30, 25, 20, 0.1);
  background: var(--paper-strong, #fbf8f3);
  box-shadow: 0 16px 40px rgba(30, 25, 20, 0.16);
}

.qq-group-close {
  position: absolute;
  top: 6px;
  inset-inline-end: 8px;
  width: 32px;
  height: 32px;
  font-size: 1.3rem;
  line-height: 1;
  color: rgba(30, 25, 20, 0.5);
}

.qq-group-close:hover {
  color: var(--ink, #1e1914);
}

.qq-group-title {
  margin: 0;
  margin-inline-end: 28px;
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.35;
}

.community-block + .community-block {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(30, 25, 20, 0.08);
}

.community-kicker {
  margin: 10px 0 0;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--ink-faint, rgba(30, 25, 20, 0.46));
}

.community-name {
  margin: 6px 0 0;
  font-weight: 650;
  line-height: 1.35;
}

.community-link {
  width: 100%;
  margin-top: 12px;
}

.qq-group-lead {
  margin: 8px 0 0;
  color: var(--ink-soft, rgba(30, 25, 20, 0.72));
  font-size: 0.88rem;
  line-height: 1.45;
}

.qq-group-number-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 12px 0 0;
  color: var(--ink-soft, rgba(30, 25, 20, 0.72));
  font-size: 0.88rem;
}

.qq-group-number-row strong {
  color: var(--ink, #1e1914);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
  user-select: all;
}

.qq-group-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.qq-group-join,
.qq-group-copy {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 650;
  text-align: center;
}

.qq-group-join {
  background: var(--ink, #1e1914);
  color: #fffaf4;
}

.qq-group-join:hover {
  background: #2e2620;
}

.qq-group-copy {
  border: 1px solid rgba(30, 25, 20, 0.16);
  background: rgba(255, 251, 246, 0.8);
}

.qq-group-copy:hover {
  border-color: rgba(30, 25, 20, 0.32);
}

.qq-group-status {
  margin: 8px 0 0;
  min-height: 0;
  font-size: 0.82rem;
  line-height: 1.4;
  color: var(--ink-soft, rgba(30, 25, 20, 0.72));
}

.qq-group-status:empty {
  display: none;
}

.qq-group-status.is-failed {
  color: #8a4b2d;
}

#lang-select {
  appearance: none;
  -webkit-appearance: none;
  font: inherit;
  font-size: 0.92rem;
  color: var(--ink, #1e1914);
  background-color: rgba(255, 251, 246, 0.72);
  /* Chevron drawn inline so no extra asset is needed. */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23736357' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  border: 1px solid rgba(30, 25, 20, 0.16);
  border-radius: 8px;
  padding: 8px 34px 8px 14px;
  cursor: pointer;
  transition: border-color 0.18s ease, background-color 0.18s ease;
}

#lang-select:hover {
  border-color: rgba(30, 25, 20, 0.32);
}

#lang-select:focus-visible {
  outline: 2px solid var(--accent, #c97953);
  outline-offset: 2px;
}

/* ===== RTL support (e.g. Arabic) ===== */
[dir="rtl"] #lang-select {
  background-position: left 12px center;
  padding: 8px 14px 8px 34px;
}

[dir="rtl"] .hero-kicker,
[dir="rtl"] .history-kicker {
  letter-spacing: 0;
}

/* Keep the brand mark / Latin product name visually LTR inside an RTL page. */
[dir="rtl"] .logo {
  direction: ltr;
}

/* Flip directional spacing that was set with physical left/right margins. */
[dir="rtl"] .stat {
  text-align: right;
}

.result-note{margin-top:12px;padding:10px 12px;border-radius:10px;background:rgba(201,121,83,.12);color:#8a4b2d;font-size:.92rem;line-height:1.4}
.result-note.hidden{display:none}

/* ===== Source mode toggle (URL / HTML upload) ===== */
.source-mode {
  display: inline-flex;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  gap: 4px;
  margin-bottom: 14px;
}

.mode-btn {
  appearance: none;
  border: 0;
  border-radius: 8px;
  padding: 8px 16px;
  font: inherit;
  font-size: .88rem;
  font-weight: 600;
  color: var(--ink-soft);
  background: transparent;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

.mode-btn:hover {
  color: var(--ink);
}

.mode-btn.active {
  background: var(--accent);
  color: #fff8f2;
}

.html-input-wrap.hidden,
.source-mode + .url-input-wrap.hidden {
  display: none;
}

.html-dropzone {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 18px 20px;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--surface);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}

.html-dropzone:hover,
.html-dropzone.dragover {
  border-color: var(--accent-warm);
  background: var(--surface-strong);
}

.html-dropzone.has-file {
  border-style: solid;
  border-color: var(--success);
}

.html-dropzone-label {
  font-size: .95rem;
  font-weight: 600;
  color: var(--ink);
  word-break: break-all;
}

.html-dropzone-hint {
  font-size: .8rem;
  color: var(--ink-faint);
  line-height: 1.5;
}

.history-badge-html {
  display: inline-flex;
  align-items: center;
  height: 20px;
  margin-inline-start: 8px;
  padding: 0 8px;
  border-radius: 6px;
  background: rgba(79, 113, 90, 0.14);
  color: var(--success);
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .04em;
  vertical-align: middle;
}

/* ===== History selection mode (bulk clean-up) ===== */
.history-check input,
.history-select-all input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
}

.history-check {
  display: none;
  align-items: center;
  flex-shrink: 0;
}

.history-list.selecting .history-check {
  display: inline-flex;
}

.history-list.selecting .history-card {
  padding-inline: 12px;
  margin-inline: -12px;
  border-radius: 12px;
  cursor: pointer;
}

.history-card.selected {
  background: rgba(201, 121, 83, 0.08);
}

.history-list.selecting .history-actions {
  display: none;
}

.history-select-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.history-select-all {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-soft);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
}

.history-select-count {
  color: var(--ink-faint);
  font-size: 0.84rem;
}

.history-select-actions {
  display: inline-flex;
  gap: 10px;
  margin-inline-start: auto;
}

.history-delete-selected {
  color: #9f4b42;
  border-color: rgba(186, 96, 81, 0.35);
  background: rgba(186, 96, 81, 0.08);
}

.history-delete-selected:hover {
  background: rgba(186, 96, 81, 0.14);
}

.history-delete-selected:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

/* ===== Visibility + tags picker (build form) ===== */
.visibility-row {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin-bottom: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.visibility-control {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.visibility-label {
  color: var(--ink-faint);
  font-size: 0.86rem;
  font-weight: 600;
}

.visibility-toggle {
  margin-bottom: 0;
}

.tags-picker {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}

.tags-builtins {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-chip {
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid rgba(30, 25, 20, 0.14);
  border-radius: 8px;
  background: rgba(250, 246, 240, 0.94);
  color: var(--ink-soft);
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}

.tag-chip:hover {
  color: var(--ink);
}

.tag-chip.active {
  border-color: rgba(201, 121, 83, 0.5);
  background: rgba(201, 121, 83, 0.13);
  color: var(--accent-deep, #8a4b2d);
}

.tags-custom-row input {
  min-height: 46px;
  width: 100%;
  padding: 10px 14px;
  border: 1px solid rgba(30, 25, 20, 0.1);
  border-radius: 10px;
  background: rgba(250, 246, 240, 0.94);
  font-size: 0.95rem;
}

.tags-custom-row input:focus {
  border-color: rgba(201, 121, 83, 0.5);
  background: rgba(255, 252, 246, 1);
}

/* ===== Market ===== */
#market-section {
  width: min(1320px, 100%);
  margin: 0 auto 84px;
}

.market-shell {
  overflow: hidden;
}

.market-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  padding: 28px 30px 20px;
  border-bottom: 1px solid rgba(30, 25, 20, 0.08);
}

.market-head h2 {
  margin-top: 8px;
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 600;
}

.market-toolbar {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.market-search {
  min-height: 42px;
  width: min(260px, 100%);
  padding: 8px 14px;
  border: 1px solid rgba(30, 25, 20, 0.14);
  border-radius: 8px;
  background: rgba(250, 246, 240, 0.94);
  font-size: 0.9rem;
}

.market-search:focus {
  border-color: rgba(201, 121, 83, 0.5);
  background: rgba(255, 252, 246, 1);
}

.market-sort {
  min-height: 42px;
  padding: 8px 34px 8px 14px;
  border: 1px solid rgba(30, 25, 20, 0.14);
  border-radius: 8px;
  background-color: rgba(250, 246, 240, 0.94);
  font-size: 0.88rem;
  color: var(--ink);
  cursor: pointer;
}

.market-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 16px 30px 4px;
}

.market-tab {
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid rgba(30, 25, 20, 0.1);
  border-radius: 8px;
  background: rgba(250, 246, 240, 0.94);
  color: rgba(30, 25, 20, 0.62);
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition), color var(--transition);
}

.market-tab:hover {
  color: var(--ink);
}

.market-tab.active {
  border-color: rgba(201, 121, 83, 0.5);
  background: rgba(201, 121, 83, 0.13);
  color: var(--ink);
}

.market-body {
  padding: 16px 30px 30px;
}

.market-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.market-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
  border: 1px solid rgba(30, 25, 20, 0.08);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.5);
  transition: border-color var(--transition), background var(--transition);
}

.market-card:hover {
  border-color: rgba(30, 25, 20, 0.16);
  background: rgba(255, 255, 255, 0.85);
}

.market-card-top {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.market-card-icon {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border-radius: 10px;
  border: 1px solid rgba(30, 25, 20, 0.08);
  background: rgba(255, 255, 255, 0.7);
  object-fit: cover;
}

.market-card-name {
  font-size: 1rem;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.market-card-url {
  margin-top: 3px;
  overflow: hidden;
  color: rgba(30, 25, 20, 0.5);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.78rem;
}

.market-card-desc {
  margin-top: 8px;
  overflow: hidden;
  color: var(--ink-soft, rgba(30, 25, 20, 0.68));
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.84rem;
}

.about-images-preview {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.about-images-preview img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid rgba(30, 25, 20, 0.12);
}

.market-count {
  display: inline-block;
  margin-top: 8px;
  padding: 3px 10px;
  border: 1px solid rgba(30, 25, 20, 0.12);
  border-radius: 999px;
  background: rgba(30, 25, 20, 0.04);
  color: rgba(30, 25, 20, 0.55);
  font-size: 0.78rem;
  font-weight: 600;
}

.market-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.market-tag {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 10px;
  border-radius: 6px;
  background: rgba(201, 121, 83, 0.12);
  color: var(--accent-deep, #8a4b2d);
  font-size: 0.74rem;
  font-weight: 700;
}

.market-card-meta {
  display: flex;
  gap: 14px;
  color: rgba(30, 25, 20, 0.55);
  font-size: 0.8rem;
}

.market-card-open {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  margin-top: auto;
  padding: 0 14px;
  border: 1px solid rgba(30, 25, 20, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.6);
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition);
}

.market-card-open:hover {
  background: rgba(255, 255, 255, 0.95);
}

/* History card: visibility switch */
.history-visibility {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid rgba(30, 25, 20, 0.12);
  border-radius: 6px;
  background: transparent;
  color: var(--ink-faint);
  font-size: 0.74rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}

.history-visibility.is-public {
  border-color: rgba(201, 121, 83, 0.45);
  background: rgba(201, 121, 83, 0.1);
  color: var(--accent-deep, #8a4b2d);
}

.history-visibility:hover {
  border-color: rgba(201, 121, 83, 0.5);
}

@media (max-width: 720px) {
  .market-head {
    padding: 22px 20px 16px;
  }

  .market-tabs {
    padding: 14px 20px 4px;
  }

  .market-body {
    padding: 14px 20px 24px;
  }

  .market-toolbar {
    width: 100%;
  }

  .market-search {
    flex: 1;
  }
}

/* --- user profile button + modal --- */
.profile-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: 999px;
  color: var(--ink, #1e1914);
  border: 1px solid rgba(30, 25, 20, 0.16);
  background-color: rgba(255, 251, 246, 0.72);
  cursor: pointer;
  padding: 0;
  overflow: hidden;
  transition: border-color 0.18s ease, color 0.18s ease;
}

.profile-btn:hover {
  border-color: rgba(30, 25, 20, 0.32);
  color: var(--accent, #c97953);
}

.profile-btn-avatar {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(30, 25, 20, 0.4);
  backdrop-filter: blur(4px);
}

.profile-card {
  position: relative;
  width: min(560px, 100%);
  max-height: 85vh;
  overflow-y: auto;
  padding: 26px;
  border-radius: 16px;
  border: 1px solid rgba(30, 25, 20, 0.1);
  background: var(--paper, #f7f3ec);
  box-shadow: 0 18px 60px rgba(30, 25, 20, 0.25);
}

.profile-close {
  position: absolute;
  top: 12px;
  right: 14px;
  border: none;
  background: none;
  font-size: 1.5rem;
  line-height: 1;
  color: rgba(30, 25, 20, 0.5);
  cursor: pointer;
}

.profile-head {
  display: flex;
  align-items: center;
  gap: 16px;
}

.profile-avatar-wrap {
  position: relative;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.profile-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid rgba(30, 25, 20, 0.16);
}

.profile-avatar-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #efe5d6;
  color: #8a7a64;
  font-size: 1.6rem;
  font-weight: 700;
}

.avatar-upload-btn {
  border: 1px solid rgba(30, 25, 20, 0.16);
  border-radius: 8px;
  background: rgba(255, 251, 246, 0.8);
  font-size: 0.72rem;
  padding: 3px 10px;
  cursor: pointer;
  color: var(--ink);
}

.profile-id-block {
  min-width: 0;
}

.profile-name-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.profile-name-view {
  font-size: 1.3rem;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-num {
  color: rgba(30, 25, 20, 0.5);
  font-size: 0.9rem;
  font-weight: 600;
  flex-shrink: 0;
}

.profile-joined {
  margin-top: 4px;
  color: rgba(30, 25, 20, 0.5);
  font-size: 0.78rem;
}

.profile-bio {
  margin-top: 14px;
  font-size: 0.9rem;
  line-height: 1.7;
  color: rgba(30, 25, 20, 0.72);
  word-break: break-word;
}

.profile-bio code {
  background: rgba(30, 25, 20, 0.07);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.85em;
}

.profile-bio a {
  color: var(--accent, #c97953);
}

.profile-msg {
  min-height: 1.1em;
  margin: 8px 0 0;
  font-size: 0.82rem;
  color: var(--accent, #c97953);
}

.profile-edit {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 12px;
}

.profile-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.82rem;
  font-weight: 600;
  color: rgba(30, 25, 20, 0.68);
}

.profile-field input,
.profile-field textarea {
  font: inherit;
  font-weight: 400;
  padding: 9px 12px;
  border: 1px solid rgba(30, 25, 20, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.75);
  color: var(--ink);
}

.profile-edit-actions {
  display: flex;
  gap: 10px;
}

.profile-save {
  padding: 8px 20px;
  border: none;
  border-radius: 8px;
  background: var(--accent-deep, #1e1914);
  color: #fff;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
}

.profile-cancel,
.profile-edit-btn {
  padding: 8px 16px;
  border: 1px solid rgba(30, 25, 20, 0.16);
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font-size: 0.86rem;
  cursor: pointer;
}

.profile-edit-btn {
  margin-top: 12px;
}

#profile-apps-label {
  margin-top: 22px;
}

.profile-apps {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
}

.profile-app {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid rgba(30, 25, 20, 0.08);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.5);
  color: var(--ink);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
}

.profile-app img {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  object-fit: cover;
}

.profile-app-dot {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: #e7ddcf;
  flex-shrink: 0;
}

.profile-app-vis {
  margin-left: auto;
  font-style: normal;
  font-size: 0.72rem;
  font-weight: 700;
  color: rgba(30, 25, 20, 0.45);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.profile-apps-empty {
  color: rgba(30, 25, 20, 0.5);
  font-size: 0.86rem;
}

/* --- market card creator + rating --- */
.market-card-creator {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.market-creator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: var(--ink);
  text-decoration: none;
}

.market-creator:hover .market-creator-name {
  color: var(--accent, #c97953);
}

.market-creator-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid rgba(30, 25, 20, 0.1);
  flex-shrink: 0;
}

.avatar-fallback.market-creator-avatar,
.market-creator-avatar.avatar-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #efe5d6;
  color: #8a7a64;
  font-size: 0.7rem;
  font-weight: 700;
}

.market-creator-name {
  font-size: 0.84rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.market-creator-num {
  font-size: 0.78rem;
  color: rgba(30, 25, 20, 0.5);
  font-weight: 600;
}

.market-card-date {
  margin-left: auto;
  font-size: 0.76rem;
  color: rgba(30, 25, 20, 0.45);
  flex-shrink: 0;
}

.market-rating {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: rgba(30, 25, 20, 0.72);
  font-weight: 600;
}

.market-star {
  color: #e8a33d;
}

.market-rating-cnt {
  color: rgba(30, 25, 20, 0.45);
  font-weight: 400;
}

.profile-vis-badge {
  flex-shrink: 0;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(201, 121, 83, 0.14);
  color: var(--accent-deep, #8a4b2d);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.market-star-off {
  color: rgba(30, 25, 20, 0.22);
}

/* ===== P3-T2: ordinary-user Card entry (shared, one input only) ===== */
#card-entry-section {
  padding: 0 20px;
  margin-top: 4px;
}

.card-entry {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 18px 14px;
  border: 1px solid var(--line, rgba(30, 25, 20, 0.1));
  border-radius: var(--radius-lg, 12px);
  background: var(--surface, rgba(255, 252, 247, 0.76));
}

.card-entry-label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-soft, rgba(30, 25, 20, 0.72));
  letter-spacing: 0.02em;
}

.card-entry-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: stretch;
}

#card-code-input {
  min-width: 0;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line-strong, rgba(30, 25, 20, 0.16));
  border-radius: 10px;
  background: rgba(248, 243, 236, 0.84);
  color: var(--ink, #1e1914);
  font-size: 0.95rem;
  letter-spacing: 0.04em;
}

#card-code-input:focus {
  outline: none;
  border-color: var(--accent, #c97953);
  box-shadow: 0 0 0 3px rgba(201, 121, 83, 0.18);
}

#card-code-input:disabled {
  opacity: 0.6;
}

#card-resolve-btn {
  padding: 0 20px;
  border-radius: 10px;
  background: var(--ink, #1e1914);
  color: #fffaf4;
  font-weight: 650;
  white-space: nowrap;
  transition: background var(--transition, 180ms ease);
}

#card-resolve-btn:hover:not(:disabled) {
  background: #2e2620;
}

#card-resolve-btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.card-status {
  min-height: 1.2em;
  margin: 10px 0 0;
  font-size: 0.86rem;
  line-height: 1.45;
  color: var(--ink-soft, rgba(30, 25, 20, 0.72));
}

.card-status.is-ok {
  color: var(--success, #4f715a);
}

.card-status.is-error {
  color: var(--danger, #a0533d);
}

.card-open-link {
  display: inline-block;
  margin-top: 10px;
  padding: 9px 16px;
  border-radius: 10px;
  background: var(--accent, #c97953);
  color: #fff;
  font-weight: 650;
  text-decoration: none;
}

.card-open-link:hover {
  background: var(--accent-warm, #a85c3a);
}

@media (max-width: 560px) {
  #card-entry-section {
    padding: 0 14px;
  }
  .card-entry-row {
    grid-template-columns: 1fr;
  }
  #card-resolve-btn {
    min-height: 46px;
  }
}
