:root {
  color-scheme: light;
  --bg: #f6f7f8;
  --surface: #ffffff;
  --surface-muted: #eef4f1;
  --text: #16201f;
  --muted: #65706d;
  --line: #d7dedb;
  --accent: #126b5a;
  --accent-strong: #0b5548;
  --accent-soft: #d9eee7;
  --blue: #2764a7;
  --danger: #b33b35;
  --danger-soft: #f7dfdd;
  --shadow: 0 18px 50px rgba(21, 39, 35, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(246, 247, 248, 0.98)),
    repeating-linear-gradient(90deg, rgba(18, 107, 90, 0.05) 0 1px, transparent 1px 84px);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button,
a,
label {
  -webkit-tap-highlight-color: transparent;
}

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

.app-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 34px 0;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 22px;
}

.brand-mark {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid #bfe3d7;
  border-radius: 8px;
}

.brand-mark svg {
  width: 27px;
  height: 27px;
}

.topbar h1,
.topbar p,
.result-heading h2,
.result-heading p,
.recent-section h2,
.empty-state p,
.status {
  margin: 0;
}

.topbar h1 {
  font-size: clamp(1.55rem, 3vw, 2.3rem);
  line-height: 1;
}

.topbar p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.96rem;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(330px, 0.9fr);
  gap: 22px;
  align-items: start;
}

.upload-panel,
.result-panel,
.command-panel {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.upload-panel {
  display: grid;
  gap: 18px;
  padding: 20px;
}

#fileInput {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.drop-zone {
  display: grid;
  min-height: 250px;
  padding: 24px;
  place-items: center;
  align-content: center;
  gap: 12px;
  text-align: center;
  color: var(--text);
  background:
    linear-gradient(135deg, rgba(217, 238, 231, 0.84), rgba(255, 255, 255, 0.92)),
    linear-gradient(45deg, rgba(39, 100, 167, 0.06), rgba(18, 107, 90, 0.06));
  border: 1px dashed #87afa5;
  border-radius: 8px;
  cursor: pointer;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    transform 0.2s ease;
}

.drop-zone:hover,
.drop-zone:focus-visible,
.drop-zone.is-dragging {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(18, 107, 90, 0.14);
  outline: none;
  transform: translateY(-1px);
}

.drop-icon {
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  color: var(--accent);
  background: #ffffff;
  border: 1px solid #c9dfd8;
  border-radius: 8px;
}

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

.file-name {
  display: block;
  max-width: min(100%, 560px);
  overflow-wrap: anywhere;
  font-size: 1.25rem;
  font-weight: 760;
}

.file-meta {
  color: var(--muted);
  font-size: 0.95rem;
}

.ttl-field {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.ttl-field legend {
  margin-bottom: 9px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.toggle-option {
  display: flex;
  width: fit-content;
  max-width: 100%;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 760;
  cursor: pointer;
}

.toggle-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toggle-visual {
  position: relative;
  width: 46px;
  height: 26px;
  flex: 0 0 auto;
  background: #dfe7e4;
  border: 1px solid var(--line);
  border-radius: 999px;
  transition:
    background 0.2s ease,
    border-color 0.2s ease;
}

.toggle-visual::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  content: "";
  background: #ffffff;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(22, 32, 31, 0.22);
  transition: transform 0.2s ease;
}

.toggle-option input:checked + .toggle-visual {
  background: var(--accent);
  border-color: var(--accent);
}

.toggle-option input:checked + .toggle-visual::after {
  transform: translateX(20px);
}

.toggle-option input:focus-visible + .toggle-visual {
  outline: 3px solid rgba(18, 107, 90, 0.2);
  outline-offset: 2px;
}

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

.segmented-control label {
  min-width: 0;
}

.segmented-control input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented-control span {
  display: grid;
  min-height: 44px;
  padding: 0 10px;
  place-items: center;
  color: var(--muted);
  background: #f8faf9;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.92rem;
  font-weight: 750;
  text-align: center;
  white-space: nowrap;
  cursor: pointer;
  transition:
    border-color 0.2s ease,
    background 0.2s ease,
    color 0.2s ease;
}

.segmented-control input:checked + span {
  color: var(--accent-strong);
  background: var(--accent-soft);
  border-color: #8fcfc0;
}

.segmented-control input:focus-visible + span {
  outline: 3px solid rgba(18, 107, 90, 0.2);
  outline-offset: 2px;
}

.primary-button,
.secondary-button,
.icon-button {
  display: inline-grid;
  place-items: center;
  color: inherit;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
}

.primary-button,
.secondary-button {
  grid-auto-flow: column;
  gap: 9px;
  min-height: 48px;
  padding: 0 18px;
  font-weight: 800;
}

.primary-button {
  color: #ffffff;
  background: var(--accent);
}

.primary-button:hover {
  background: var(--accent-strong);
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.68;
}

.icon-button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.secondary-button {
  justify-content: center;
  color: #ffffff;
  background: var(--blue);
}

.icon-button {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  color: var(--accent);
  background: var(--accent-soft);
}

.icon-button:hover {
  filter: brightness(0.97);
}

.icon-button.danger {
  color: var(--danger);
  background: var(--danger-soft);
}

.status {
  min-height: 22px;
  color: var(--muted);
  font-size: 0.95rem;
}

.status.is-error {
  color: var(--danger);
}

.status.is-success {
  color: var(--accent-strong);
}

.result-panel {
  display: grid;
  gap: 18px;
  padding: 20px;
}

.token-download,
.field-block {
  display: grid;
  gap: 8px;
}

.token-download label,
.field-block label {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 760;
}

.empty-state {
  display: grid;
  min-height: 204px;
  place-items: center;
  align-content: center;
  gap: 12px;
  color: var(--muted);
  background: #f8faf9;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.empty-icon {
  display: grid;
  width: 56px;
  height: 56px;
  place-items: center;
  color: var(--blue);
  background: #e2edf7;
  border-radius: 8px;
}

.empty-icon svg {
  width: 30px;
  height: 30px;
}

.result {
  display: grid;
  gap: 14px;
}

.result-heading {
  display: flex;
  gap: 12px;
  align-items: start;
  justify-content: space-between;
}

.result-heading h2 {
  max-width: 100%;
  overflow-wrap: anywhere;
  font-size: 1.08rem;
  line-height: 1.25;
}

.result-heading p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.92rem;
}

.link-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px;
  gap: 9px;
}

.link-row input,
.field-block > input {
  min-width: 0;
  height: 42px;
  padding: 0 12px;
  color: var(--text);
  background: #f8faf9;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.field-block > input {
  width: 100%;
  font-family: ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.88rem;
}

.mini-commands {
  display: grid;
  gap: 8px;
}

.recent-section {
  display: grid;
  gap: 10px;
}

.recent-section h2 {
  color: var(--muted);
  font-size: 0.92rem;
}

.recent-list {
  display: grid;
  gap: 8px;
}

.recent-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.recent-item:first-child {
  border-top: 0;
}

.recent-name {
  overflow-wrap: anywhere;
  font-weight: 760;
}

.recent-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.86rem;
}

.recent-actions {
  display: flex;
  gap: 7px;
}

.recent-actions .icon-button {
  width: 36px;
  height: 36px;
}

.command-panel {
  display: grid;
  gap: 16px;
  margin-top: 22px;
  padding: 20px;
}

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

.section-heading h2,
.section-heading p,
.command-grid h3 {
  margin: 0;
}

.section-heading h2 {
  font-size: 1.08rem;
}

.section-heading p {
  color: var(--muted);
  font-size: 0.9rem;
  text-align: right;
}

.command-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.command-grid article {
  display: grid;
  min-width: 0;
  gap: 8px;
  padding: 12px;
  background: #f8faf9;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.command-grid h3 {
  color: var(--muted);
  font-size: 0.88rem;
}

.code-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 38px;
  gap: 8px;
  align-items: center;
}

.code-row code {
  min-width: 0;
  height: 38px;
  padding: 10px 11px;
  overflow: hidden;
  color: #20302e;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.82rem;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.code-row .icon-button {
  width: 38px;
  height: 38px;
}

@media (max-width: 820px) {
  .app-shell {
    width: min(100% - 22px, 680px);
    padding: 22px 0;
  }

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

  .drop-zone {
    min-height: 210px;
  }

  .section-heading {
    display: grid;
  }

  .section-heading p {
    text-align: left;
  }

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

@media (max-width: 520px) {
  .topbar {
    align-items: flex-start;
  }

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

  .upload-panel,
  .result-panel {
    padding: 14px;
  }

  .recent-item {
    grid-template-columns: 1fr;
  }
}
