:root {
  --ink: #17221c;
  --ink-soft: #405047;
  --muted: #6d786f;
  --canvas: #f3f5f1;
  --surface: #ffffff;
  --surface-alt: #f8faf7;
  --line: #d8dfd9;
  --line-strong: #bdc8bf;
  --court: #176747;
  --court-dark: #104a34;
  --court-soft: #dfeee6;
  --amber: #9b5f12;
  --amber-soft: #f6e8ca;
  --blue: #315d78;
  --blue-soft: #e2edf3;
  --danger: #a33e32;
  --danger-soft: #f8e7e3;
  --shadow: 0 12px 30px rgba(23, 34, 28, 0.08);
  --radius: 8px;
  font-family:
    "PingFang SC",
    "Hiragino Sans GB",
    "Microsoft YaHei",
    "Noto Sans CJK SC",
    sans-serif;
  color: var(--ink);
  background: var(--canvas);
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--canvas);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(90deg, rgba(23, 103, 71, 0.04) 1px, transparent 1px) 0 0 / 56px 56px,
    linear-gradient(rgba(23, 103, 71, 0.04) 1px, transparent 1px) 0 0 / 56px 56px,
    var(--canvas);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(49, 93, 120, 0.28);
  outline-offset: 2px;
}

svg {
  display: block;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

[hidden] {
  display: none !important;
}

.app-shell {
  min-height: 100vh;
}

.app-header {
  width: 100%;
  margin: 0;
  color: #f7faf7;
  background: var(--court-dark);
  border-bottom: 4px solid #d4a64b;
}

.app-header-inner {
  display: flex;
  width: min(1480px, calc(100% - 40px));
  margin: 0 auto;
  min-height: 118px;
  padding: 24px clamp(24px, 4vw, 64px);
  align-items: center;
  justify-content: space-between;
  gap: 32px;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 18px;
}

.brand-mark {
  position: relative;
  width: 46px;
  height: 46px;
  flex: 0 0 46px;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 50%;
}

.brand-mark::before,
.brand-mark::after {
  position: absolute;
  content: "";
  background: rgba(255, 255, 255, 0.55);
}

.brand-mark::before {
  top: 0;
  bottom: 0;
  left: 50%;
  width: 1px;
}

.brand-mark::after {
  top: 50%;
  right: 7px;
  left: 7px;
  height: 1px;
}

.brand-mark span {
  position: absolute;
  top: 11px;
  bottom: 11px;
  width: 9px;
  border: 1px solid rgba(255, 255, 255, 0.72);
}

.brand-mark span:first-child {
  left: 8px;
  border-right: 0;
  border-radius: 8px 0 0 8px;
}

.brand-mark span:last-child {
  right: 8px;
  border-left: 0;
  border-radius: 0 8px 8px 0;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.16em;
}

.app-header .eyebrow {
  color: #a9cbbb;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 4px;
  font-size: clamp(24px, 2.3vw, 34px);
  font-weight: 650;
  letter-spacing: 0.01em;
}

.app-subtitle {
  margin: 0;
  color: #c9ddd2;
  font-size: 13px;
}

.file-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: min(42vw, 440px);
  padding: 9px 12px;
  overflow: hidden;
  color: #e4eee8;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 7px;
  background: #98ab9f;
  border-radius: 50%;
}

.file-status.has-file .status-dot {
  background: #e1b258;
  box-shadow: 0 0 0 4px rgba(225, 178, 88, 0.14);
}

main {
  width: min(1480px, calc(100% - 40px));
  margin: 0 auto;
  padding: 22px 0 48px;
}

.tool-stage {
  display: flex;
  height: min(832.5px, calc(56.25vw - 22.5px));
  min-width: 0;
  aspect-ratio: 16 / 9;
  flex-direction: column;
}

.tool-sticky {
  position: sticky;
  z-index: 16;
  top: 0;
  flex: 0 0 auto;
  padding-top: 8px;
  background:
    linear-gradient(
      180deg,
      var(--canvas) 0,
      var(--canvas) calc(100% - 14px),
      rgba(243, 245, 241, 0.94) 100%
    );
}

.tool-stage > .notice {
  flex: 0 0 auto;
}

.tool-stage > .workspace {
  flex: 1 1 auto;
  min-height: 0;
}

.tool-stage .table-frame {
  height: 100%;
  max-height: none;
  min-height: 0;
}

.tool-stage .drop-zone {
  height: 100%;
  min-height: 0;
}

.tool-stage .bracket-panel {
  height: 100%;
  overflow: auto;
}

.control-band {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 13px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 3px 10px rgba(23, 34, 28, 0.04);
}

.toolbar,
.display-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  transition:
    background-color 140ms ease,
    border-color 140ms ease,
    color 140ms ease,
    transform 140ms ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.button:active:not(:disabled) {
  transform: translateY(0);
}

.button:disabled {
  color: #8d9790;
  background: #edf0ed;
  border-color: #e2e6e2;
  cursor: not-allowed;
}

.button-primary {
  color: #fff;
  background: var(--court);
  border-color: var(--court);
}

.button-primary:hover:not(:disabled) {
  background: var(--court-dark);
  border-color: var(--court-dark);
}

.button-secondary {
  color: var(--ink);
  background: #fff;
  border-color: var(--line-strong);
}

.button-secondary:hover:not(:disabled) {
  background: var(--surface-alt);
  border-color: #96a79b;
}

.button-export {
  color: var(--court-dark);
  background: var(--court-soft);
  border-color: #b9d5c7;
}

.button-export:hover:not(:disabled) {
  background: #d2e7dc;
  border-color: #98c1ab;
}

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

.button-quiet:hover:not(:disabled) {
  background: var(--surface-alt);
}

.segmented {
  display: inline-flex;
  padding: 3px;
  background: #e9ede8;
  border: 1px solid #dce2dc;
  border-radius: 7px;
}

.segment,
.view-tab {
  min-height: 30px;
  padding: 5px 11px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}

.segment.is-active,
.view-tab.is-active {
  color: var(--ink);
  background: #fff;
  box-shadow: 0 1px 4px rgba(23, 34, 28, 0.13);
}

.segment:disabled,
.view-tab:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.view-switch {
  display: inline-flex;
  gap: 4px;
  padding-left: 10px;
  border-left: 1px solid var(--line);
}

.notice {
  margin-top: 14px;
  padding: 14px 16px;
  color: #70392f;
  background: var(--danger-soft);
  border: 1px solid #e7bdb5;
  border-left: 4px solid var(--danger);
  border-radius: 0 var(--radius) var(--radius) 0;
}

.notice.is-info {
  color: #264e64;
  background: var(--blue-soft);
  border-color: #b8d0dc;
  border-left-color: var(--blue);
}

.notice.is-success {
  color: #235c42;
  background: var(--court-soft);
  border-color: #b9d5c7;
  border-left-color: var(--court);
}

.notice-heading {
  display: flex;
  align-items: center;
  gap: 8px;
}

.notice-heading strong {
  font-size: 13px;
}

.notice p {
  margin: 6px 0 0;
  font-size: 13px;
}

.notice ul {
  display: grid;
  gap: 4px;
  margin: 9px 0 0;
  padding-left: 25px;
  font-size: 12px;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(110px, 1fr));
  margin: 18px 0 14px;
  background: rgba(255, 255, 255, 0.68);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.summary-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  min-height: 62px;
  padding: 13px 18px;
  border-right: 1px solid var(--line);
}

.summary-item:last-child {
  border-right: 0;
}

.summary-label {
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
}

.summary-value {
  font-variant-numeric: tabular-nums;
  font-size: 23px;
  font-weight: 650;
}

.workspace {
  position: relative;
  min-height: 470px;
}

.draw-progress {
  position: absolute;
  z-index: 6;
  inset: 0;
  display: grid;
  padding: 22px;
  background: rgba(243, 245, 241, 0.9);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  opacity: 0;
  pointer-events: none;
  place-items: center;
  backdrop-filter: blur(3px);
  transition: opacity 160ms ease-out;
}

.draw-progress.is-visible {
  opacity: 1;
}

.draw-progress-panel {
  display: grid;
  width: min(420px, 100%);
  padding: 26px 24px 24px;
  justify-items: center;
  text-align: center;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid #b9d5c7;
  border-radius: var(--radius);
  box-shadow: 0 18px 48px rgba(23, 34, 28, 0.14);
}

.shuffle-stage {
  display: flex;
  height: 66px;
  margin-bottom: 18px;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

.shuffle-tile {
  display: grid;
  width: 42px;
  height: 52px;
  color: #fff;
  background: var(--court);
  border: 1px solid var(--court-dark);
  border-radius: 6px;
  box-shadow: 0 8px 18px rgba(16, 74, 52, 0.18);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  font-weight: 700;
  place-items: center;
  animation: shuffle-position 880ms ease-in-out infinite alternate;
}

.shuffle-tile:nth-child(2) {
  animation-delay: -140ms;
  animation-duration: 760ms;
}

.shuffle-tile:nth-child(3) {
  color: #70460e;
  background: #f2cc78;
  border-color: #c28a30;
  animation-delay: -320ms;
  animation-duration: 980ms;
}

.shuffle-tile:nth-child(4) {
  animation-delay: -80ms;
  animation-duration: 820ms;
}

.shuffle-tile:nth-child(5) {
  animation-delay: -240ms;
  animation-duration: 920ms;
}

.draw-progress.is-settling .shuffle-tile {
  animation: none;
  opacity: 0.82;
  transform: translateY(0) rotate(0);
}

.draw-progress-panel strong {
  font-size: 17px;
  font-weight: 650;
}

.draw-progress-panel > span:last-child {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  text-wrap: pretty;
}

@keyframes shuffle-position {
  0% {
    transform: translate3d(-4px, 7px, 0) rotate(-5deg);
  }

  45% {
    transform: translate3d(5px, -8px, 0) rotate(4deg);
  }

  100% {
    transform: translate3d(-2px, 3px, 0) rotate(-2deg);
  }
}

.drop-zone {
  display: flex;
  width: 100%;
  min-height: 470px;
  padding: 42px 24px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  color: var(--ink-soft);
  background:
    linear-gradient(135deg, transparent 49.6%, rgba(23, 103, 71, 0.09) 49.7%, rgba(23, 103, 71, 0.09) 50.3%, transparent 50.4%),
    var(--surface);
  background-size: 30px 30px;
  border: 1px dashed #9cb3a5;
  border-radius: var(--radius);
  cursor: pointer;
  transition:
    border-color 150ms ease,
    background-color 150ms ease;
}

.drop-zone:hover,
.drop-zone.is-dragging {
  background-color: #f8fbf8;
  border-color: var(--court);
}

.drop-icon {
  display: grid;
  width: 58px;
  height: 58px;
  margin-bottom: 19px;
  color: var(--court);
  background: var(--court-soft);
  border: 1px solid #b9d5c7;
  border-radius: 50%;
  place-items: center;
}

.drop-icon svg {
  width: 25px;
  height: 25px;
}

.drop-title {
  color: var(--ink);
  font-size: 18px;
  font-weight: 650;
}

.drop-caption {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.table-frame {
  overflow: auto;
  max-height: calc(100vh - 330px);
  min-height: 470px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

table {
  width: 100%;
  min-width: 780px;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
}

th {
  position: sticky;
  z-index: 2;
  top: 0;
  height: 45px;
  padding: 10px 16px;
  color: #eef5f0;
  background: #2a3b32;
  border-right: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 12px;
  font-weight: 650;
  text-align: left;
  white-space: nowrap;
}

th:last-child {
  border-right: 0;
}

td {
  height: 46px;
  padding: 9px 16px;
  overflow: hidden;
  color: var(--ink-soft);
  background: var(--surface);
  border-right: 1px solid #edf0ed;
  border-bottom: 1px solid #e7ebe7;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

td:last-child {
  border-right: 0;
}

.table-frame th {
  height: 52px;
  font-size: 14px;
  font-weight: 700;
}

.table-frame td {
  height: 54px;
  font-size: 16px;
  font-weight: 500;
}

tbody tr:nth-child(even) td {
  background: #fafbf9;
}

tbody tr:hover td {
  background: #f2f8f4;
}

tbody tr.has-seed td:first-child {
  box-shadow: inset 3px 0 0 #c58a2f;
}

.position-column {
  width: 120px;
}

.unit-column {
  width: 29%;
}

.number-column {
  width: 120px;
}

.position-value,
.number-value {
  font-variant-numeric: tabular-nums;
}

.position-value {
  color: var(--ink);
  font-size: 17px;
  font-weight: 700;
}

.empty-value {
  color: #9ba49d;
}

.seed-badge {
  display: inline-flex;
  min-width: 52px;
  min-height: 27px;
  padding: 3px 9px;
  align-items: center;
  justify-content: center;
  color: #74470a;
  background: var(--amber-soft);
  border: 1px solid #e6ce9e;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.bracket-panel {
  padding: 16px;
  background: #eef2ed;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
}

.seo-guide {
  margin-top: 56px;
  padding: 44px 0 8px;
  border-top: 1px solid var(--line-strong);
}

.guide-intro {
  max-width: 960px;
}

.guide-intro .eyebrow {
  color: var(--court);
}

.guide-intro h2 {
  margin: 0 0 14px;
  color: var(--ink);
  font-size: clamp(24px, 2.2vw, 30px);
  font-weight: 650;
  letter-spacing: 0;
  line-height: 1.3;
  text-wrap: balance;
}

.guide-intro > p:last-child {
  max-width: 900px;
  margin-bottom: 0;
  color: var(--ink-soft);
  font-size: 15px;
  line-height: 1.85;
  text-wrap: pretty;
}

.guide-grid {
  display: grid;
  margin-top: 34px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 32px 48px;
}

.guide-topic {
  padding-left: 20px;
  border-left: 2px solid #b9d5c7;
}

.guide-topic:last-child {
  grid-column: 1 / -1;
  border-left-color: #b8d0dc;
}

.guide-topic h3 {
  margin: 0 0 10px;
  color: var(--ink);
  font-size: 17px;
  font-weight: 650;
  line-height: 1.4;
}

.guide-topic p {
  margin-bottom: 12px;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.8;
  text-wrap: pretty;
}

.guide-topic p:last-child {
  margin-bottom: 0;
}

.guide-topic code {
  padding: 1px 5px;
  color: var(--court-dark);
  background: var(--court-soft);
  border-radius: 4px;
  font-size: 12px;
}

.guide-columns {
  display: grid;
  margin: 14px 0;
  padding: 0;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 18px;
  list-style: none;
}

.guide-columns li {
  display: grid;
  padding: 9px 0;
  border-top: 1px solid var(--line);
  gap: 2px;
}

.guide-columns strong {
  color: var(--ink);
  font-size: 12px;
}

.guide-columns span {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}

.excel-example {
  margin: 18px 0 12px;
}

.excel-example img {
  display: block;
  width: 100%;
  height: auto;
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  outline: 1px solid rgba(0, 0, 0, 0.04);
  outline-offset: -1px;
}

.excel-example figcaption {
  margin-top: 8px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
  text-wrap: pretty;
}

.guide-download {
  display: inline-flex;
  min-height: 40px;
  margin-bottom: 14px;
  padding: 9px 13px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: #fff;
  background: var(--court);
  border: 1px solid var(--court);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 650;
  text-decoration: none;
  transition:
    background-color 140ms ease,
    border-color 140ms ease,
    transform 140ms ease;
}

.guide-download:hover {
  background: var(--court-dark);
  border-color: var(--court-dark);
  transform: translateY(-1px);
}

.guide-download:active {
  transform: translateY(0);
}

.guide-download svg {
  width: 16px;
  height: 16px;
}

.guide-workflow {
  display: grid;
  margin: 18px 0 0;
  padding: 0;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 20px;
  counter-reset: guide-step;
  list-style: none;
}

.guide-workflow li {
  position: relative;
  padding-top: 38px;
  border-top: 1px solid var(--line-strong);
}

.guide-workflow li::before {
  position: absolute;
  top: 12px;
  left: 0;
  color: var(--court);
  content: counter(guide-step, decimal-leading-zero);
  counter-increment: guide-step;
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  font-weight: 700;
}

.guide-workflow strong {
  display: block;
  color: var(--ink);
  font-size: 13px;
}

.guide-workflow p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.65;
}

.guide-more {
  margin: 30px 0 0;
  font-size: 14px;
}

.guide-more a {
  color: var(--court);
  font-weight: 650;
  text-underline-offset: 3px;
}

.guide-note {
  margin: 30px 0 0;
  padding-top: 18px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  font-size: 11px;
  line-height: 1.7;
}

.article-header {
  width: 100%;
  margin: 0;
  color: #f7faf7;
  background: var(--court-dark);
  border-bottom: 4px solid #d4a64b;
}

.article-header-inner {
  display: flex;
  width: min(980px, calc(100% - 40px));
  margin: 0 auto;
  min-height: 92px;
  padding: 18px 0;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.article-brand {
  display: flex;
  align-items: center;
  gap: 13px;
  color: inherit;
  text-decoration: none;
}

.article-brand .brand-mark {
  width: 40px;
  height: 40px;
  flex-basis: 40px;
}

.article-brand .brand-mark span {
  top: 9px;
  bottom: 9px;
}

.article-brand .brand-mark span:first-child {
  left: 7px;
}

.article-brand .brand-mark span:last-child {
  right: 7px;
}

.article-brand-copy {
  display: grid;
  gap: 2px;
}

.article-brand .eyebrow {
  margin: 0;
  color: #a9cbbb;
}

.article-brand-name {
  font-size: 18px;
  font-weight: 650;
  line-height: 1.3;
}

.article-tool-link {
  flex: 0 0 auto;
  text-decoration: none;
  white-space: nowrap;
}

.article-shell {
  width: min(980px, calc(100% - 40px));
  margin: 0 auto;
  padding: 24px 0 64px;
}

.breadcrumbs ol {
  display: flex;
  margin: 0;
  padding: 0;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 11px;
  list-style: none;
}

.breadcrumbs li:not(:last-child)::after {
  margin-left: 9px;
  color: #9ba49d;
  content: "/";
}

.breadcrumbs a {
  color: var(--court);
  text-underline-offset: 2px;
}

.seo-article {
  margin-top: 18px;
}

.article-hero {
  padding: 28px 0 32px;
  border-bottom: 1px solid var(--line-strong);
}

.article-hero .eyebrow {
  color: var(--court);
}

.article-hero h1 {
  max-width: 100%;
  margin: 0 0 18px;
  font-size: clamp(30px, 3.6vw, 46px);
  font-weight: 680;
  letter-spacing: 0;
  line-height: 1.18;
  text-wrap: balance;
}

.article-hero h1 span {
  display: inline-block;
  white-space: nowrap;
}

.article-lede {
  max-width: 780px;
  margin: 0;
  color: var(--ink-soft);
  font-size: 16px;
  line-height: 1.9;
  text-wrap: pretty;
}

.article-meta {
  display: flex;
  margin: 20px 0 0;
  flex-wrap: wrap;
  gap: 8px 18px;
  color: var(--muted);
  font-size: 11px;
}

.article-toc {
  display: grid;
  margin: 28px 0 0;
  padding: 20px 22px;
  grid-template-columns: 90px minmax(0, 1fr);
  gap: 20px;
  background: rgba(255, 255, 255, 0.7);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.article-toc > strong {
  color: var(--ink);
  font-size: 12px;
}

.article-toc ol {
  display: grid;
  margin: 0;
  padding: 0;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 28px;
  list-style: none;
}

.article-toc a {
  color: var(--ink-soft);
  font-size: 13px;
  text-decoration-color: #b9d5c7;
  text-underline-offset: 3px;
}

.article-section {
  padding: 34px 0;
  border-bottom: 1px solid var(--line);
  scroll-margin-top: 24px;
}

.article-section h2 {
  margin: 0 0 16px;
  color: var(--ink);
  font-size: 25px;
  font-weight: 660;
  letter-spacing: 0;
  line-height: 1.35;
}

.article-section p {
  margin: 0 0 14px;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.95;
  text-wrap: pretty;
}

.article-section p:last-child {
  margin-bottom: 0;
}

.article-section a {
  color: var(--court);
  font-weight: 600;
  text-underline-offset: 3px;
}

.article-section code {
  padding: 1px 5px;
  color: var(--court-dark);
  background: var(--court-soft);
  border-radius: 4px;
  font-size: 12px;
}

.article-table-wrap {
  margin: 20px 0;
  overflow-x: auto;
  border: 1px solid var(--line-strong);
}

.article-table {
  min-width: 620px;
  table-layout: auto;
}

.article-table th {
  position: static;
  height: auto;
  padding: 10px 12px;
  color: var(--ink);
  background: #eef2ed;
  border-right: 1px solid var(--line);
  white-space: normal;
}

.article-table th:last-child {
  border-right: 0;
}

.article-table td {
  height: auto;
  padding: 10px 12px;
  overflow: visible;
  background: #fff;
  border-right: 1px solid var(--line);
  text-overflow: clip;
  white-space: normal;
}

.article-table td:last-child {
  border-right: 0;
}

.article-example {
  margin: 20px 0;
  padding: 18px 20px;
  color: #235c42;
  background: var(--court-soft);
  border-left: 3px solid var(--court);
}

.article-example strong {
  display: block;
  font-size: 14px;
}

.article-example p {
  margin: 6px 0 10px;
  color: #315b45;
  font-size: 12px;
}

.article-example code {
  color: var(--court-dark);
  background: rgba(255, 255, 255, 0.56);
}

.article-cta {
  display: flex;
  margin-top: 34px;
  padding: 24px 28px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  color: #f7faf7;
  background: var(--court-dark);
  border-radius: var(--radius);
}

.article-cta strong {
  font-size: 16px;
}

.article-cta p {
  margin: 5px 0 0;
  color: #c9ddd2;
  font-size: 12px;
}

.article-cta .button {
  flex: 0 0 auto;
  text-decoration: none;
  white-space: nowrap;
}

.article-footer {
  display: flex;
  padding: 22px clamp(24px, 5vw, 72px);
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  color: #c9ddd2;
  background: #24382d;
  font-size: 11px;
}

.article-footer a {
  color: #fff;
  text-underline-offset: 3px;
}

.bracket-legend {
  display: flex;
  justify-content: flex-end;
  gap: 18px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 11px;
}

.bracket-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-mark {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.seed-mark {
  background: #c58a2f;
}

.bye-mark {
  background: var(--blue);
}

.athlete-mark {
  background: var(--court);
}

.slot-grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 7px;
}

.slot {
  position: relative;
  min-height: 70px;
  padding: 8px 9px 8px 38px;
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.slot.is-seed {
  background: #fffaf0;
  border-color: #e0c58f;
}

.slot.is-bye {
  background: var(--blue-soft);
  border-color: #b9ceda;
}

.slot-position {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  display: flex;
  width: 30px;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: #64736a;
  font-variant-numeric: tabular-nums;
  font-size: 10px;
  writing-mode: vertical-rl;
  letter-spacing: 0.04em;
}

.slot.is-seed .slot-position {
  background: #b57820;
}

.slot.is-bye .slot-position {
  background: var(--blue);
}

.slot-name {
  display: block;
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.slot-unit {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.slot-seed {
  display: inline-block;
  margin-top: 5px;
  color: var(--amber);
  font-size: 10px;
  font-weight: 700;
}

.slot-bye-label {
  display: flex;
  height: 100%;
  flex-direction: column;
  justify-content: center;
  color: #42657a;
  font-size: 11px;
  font-weight: 650;
}

.slot-bye-label small {
  margin-top: 2px;
  font-size: 9px;
  font-weight: 500;
}

.dialog {
  width: min(480px, calc(100% - 32px));
  padding: 0;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: 0 24px 70px rgba(16, 37, 26, 0.24);
}

.dialog::backdrop {
  background: rgba(14, 27, 20, 0.56);
  backdrop-filter: blur(2px);
}

.dialog form,
.dialog-compact {
  padding: 22px;
}

.dialog-compact {
  padding: 22px;
}

.dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.dialog h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 650;
}

.icon-button {
  display: grid;
  width: 34px;
  height: 34px;
  padding: 0;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  place-items: center;
}

.icon-button:hover {
  color: var(--ink);
  background: var(--surface-alt);
}

.field-label {
  display: block;
  margin-bottom: 7px;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 650;
}

.file-name-field {
  display: flex;
  align-items: stretch;
  overflow: hidden;
  background: var(--surface-alt);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
}

.file-name-field:focus-within {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(49, 93, 120, 0.12);
}

.file-name-field input {
  width: 100%;
  min-width: 0;
  padding: 11px 12px;
  color: var(--ink);
  background: transparent;
  border: 0;
  outline: 0;
}

.file-name-field span {
  display: flex;
  padding: 0 12px;
  align-items: center;
  color: var(--muted);
  background: #eef1ed;
  border-left: 1px solid var(--line);
  font-size: 12px;
}

.field-hint {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 24px;
}

.dialog-compact #confirmMessage {
  margin-bottom: 4px;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.65;
}

.toast {
  position: fixed;
  z-index: 20;
  right: 24px;
  bottom: 24px;
  max-width: min(420px, calc(100% - 32px));
  padding: 11px 14px;
  color: #fff;
  background: #24382d;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 6px;
  box-shadow: 0 14px 36px rgba(15, 28, 21, 0.22);
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.toast.is-error {
  background: #74352c;
}

@media (max-width: 980px) {
  .tool-stage {
    height: max(640px, calc(100dvh - 20px));
    aspect-ratio: auto;
  }

  .control-band {
    align-items: flex-start;
    flex-direction: column;
  }

  .display-controls {
    width: 100%;
    justify-content: space-between;
  }

  .slot-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

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

  .guide-topic:last-child {
    grid-column: auto;
  }

  .guide-workflow {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .article-shell {
    width: min(760px, calc(100% - 32px));
  }

  .article-header-inner {
    width: min(760px, calc(100% - 32px));
  }

  .article-toc {
    grid-template-columns: 1fr;
    gap: 12px;
  }
}

@media (max-width: 720px) {
  .app-header {
    width: 100%;
  }

  .app-header-inner {
    width: calc(100% - 24px);
    min-height: 0;
    padding: 20px 16px;
    align-items: flex-start;
    flex-direction: column;
    gap: 16px;
  }

  .brand-mark {
    width: 40px;
    height: 40px;
    flex-basis: 40px;
  }

  .file-status {
    max-width: 100%;
  }

  main {
    width: calc(100% - 24px);
    padding-top: 12px;
  }

  .control-band {
    padding: 12px;
  }

  .toolbar {
    width: 100%;
  }

  .toolbar .button {
    flex: 1 1 160px;
  }

  .summary-strip {
    grid-template-columns: repeat(5, minmax(92px, 1fr));
    overflow-x: auto;
  }

  .summary-item {
    min-height: 58px;
    padding: 10px 12px;
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
  }

  .summary-value {
    font-size: 19px;
  }

  .drop-zone {
    min-height: 380px;
    padding-right: 18px;
    padding-left: 18px;
  }

  .drop-title {
    max-width: 290px;
    font-size: 16px;
    line-height: 1.5;
    text-align: center;
  }

  .drop-caption {
    max-width: 290px;
    line-height: 1.5;
    text-align: center;
  }

  .table-frame {
    max-height: none;
    min-height: 380px;
  }

  .slot-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .bracket-panel {
    padding: 10px;
  }

  .seo-guide {
    margin-top: 34px;
    padding-top: 30px;
  }

  .guide-intro h2 {
    font-size: 23px;
  }

  .guide-grid {
    margin-top: 26px;
    gap: 24px;
  }

  .guide-topic {
    padding-left: 14px;
  }

  .guide-columns,
  .guide-workflow {
    grid-template-columns: 1fr;
  }

  .guide-more {
    line-height: 1.7;
  }

  .article-header-inner {
    width: calc(100% - 24px);
    padding: 18px 0;
    align-items: stretch;
    flex-direction: column;
    gap: 14px;
  }

  .article-tool-link {
    width: 100%;
    justify-content: center;
  }

  .article-shell {
    width: calc(100% - 24px);
    padding-top: 18px;
  }

  .article-hero {
    padding: 22px 0 26px;
  }

  .article-hero h1 {
    font-size: 30px;
    line-height: 1.28;
  }

  .article-lede {
    font-size: 15px;
  }

  .article-toc {
    padding: 18px;
  }

  .article-toc ol {
    grid-template-columns: 1fr;
  }

  .article-section {
    padding: 28px 0;
  }

  .article-section h2 {
    font-size: 22px;
  }

  .article-table {
    min-width: 0;
  }

  .article-table th,
  .article-table td {
    padding: 7px 6px;
    font-size: 10px;
    line-height: 1.45;
  }

  .article-cta {
    padding: 22px;
    align-items: flex-start;
    flex-direction: column;
  }

  .article-footer {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
