:root {
  color-scheme: light;
  --bg: #f6f7f3;
  --panel: #ffffff;
  --panel-soft: #fafaf7;
  --text: #1f2528;
  --muted: #667078;
  --line: #d9ded8;
  --line-strong: #bdc7c1;
  --accent: #0f766e;
  --accent-dark: #0b5f58;
  --accent-soft: #dff4ef;
  --warning: #9a5b13;
  --warning-bg: #fff5df;
  --danger: #b42318;
  --shadow: 0 16px 42px rgba(31, 37, 40, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  background:
    linear-gradient(180deg, rgba(15, 118, 110, 0.08), rgba(255, 255, 255, 0) 340px),
    var(--bg);
  color: var(--text);
  font-family:
    Inter, "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  letter-spacing: 0;
}

button,
input,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

.app-shell {
  width: min(1480px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 22px 0 30px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 78px;
}

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

.brand-mark {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border: 1px solid rgba(15, 118, 110, 0.24);
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-dark);
}

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

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  line-height: 1.2;
  font-weight: 730;
}

h2 {
  font-size: 16px;
  line-height: 1.3;
  font-weight: 720;
}

h3 {
  font-size: 14px;
  line-height: 1.3;
  font-weight: 700;
}

.brand-block p,
.result-header p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.settings-grid {
  display: grid;
  grid-template-columns: minmax(180px, 220px) minmax(150px, 180px);
  gap: 10px;
}

.field {
  display: grid;
  gap: 6px;
}

.field span {
  color: var(--muted);
  font-size: 12px;
}

.field input {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  padding: 8px 10px;
  outline: none;
}

.field input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.13);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(340px, 440px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.input-panel,
.result-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.input-panel {
  padding: 16px;
}

.result-panel {
  min-width: 0;
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.result-header {
  min-height: 70px;
  padding: 15px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-soft);
}

.icon-button,
.primary-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  border-radius: 6px;
  border: 1px solid transparent;
  padding: 8px 12px;
  white-space: nowrap;
}

.icon-button svg,
.primary-button svg,
.secondary-button svg {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
}

.primary-button {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  font-weight: 680;
}

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

.secondary-button,
.icon-button.ghost {
  background: #fff;
  color: var(--text);
  border-color: var(--line);
}

.secondary-button:hover:not(:disabled),
.icon-button.ghost:hover:not(:disabled) {
  border-color: var(--line-strong);
  background: #f5f7f4;
}

.input-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin: 16px 0 12px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f2f4f0;
}

.switch-button {
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
}

.switch-button.active {
  background: #fff;
  color: var(--text);
  box-shadow: 0 1px 4px rgba(31, 37, 40, 0.08);
  font-weight: 650;
}

.input-pane {
  display: none;
}

.input-pane.active {
  display: grid;
  gap: 10px;
}

textarea {
  width: 100%;
  min-height: 360px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  padding: 12px;
  outline: none;
  line-height: 1.55;
}

#wordText {
  min-height: 248px;
}

.upload-zone {
  display: grid;
  grid-template-columns: 28px 1fr;
  grid-template-areas:
    "icon label"
    "icon file";
  gap: 4px 10px;
  align-items: center;
  min-height: 72px;
  border: 1px dashed var(--line-strong);
  border-radius: 7px;
  background: #fbfcfa;
  padding: 14px;
  cursor: pointer;
}

.upload-zone svg {
  grid-area: icon;
  width: 24px;
  height: 24px;
  color: var(--accent-dark);
}

.upload-zone span {
  grid-area: label;
  font-weight: 680;
}

.upload-zone strong {
  grid-area: file;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#wordFile {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.action-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-top: 12px;
}

.download-button {
  min-width: 136px;
}

.table-wrap {
  position: relative;
  min-height: 462px;
  overflow: auto;
}

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

thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  border-bottom: 1px solid var(--line-strong);
  background: #e8f1ee;
  color: #243130;
  font-size: 12px;
  font-weight: 720;
  text-align: left;
  white-space: nowrap;
}

th,
td {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 0;
}

th {
  padding: 10px;
}

td input {
  width: 100%;
  min-width: 86px;
  height: 38px;
  border: 0;
  background: #fff;
  color: var(--text);
  padding: 8px 10px;
  outline: none;
}

td input:focus {
  box-shadow: inset 0 0 0 2px var(--accent);
}

td input[readonly] {
  background: #f7f8f5;
  color: #8a9399;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 10px;
  color: var(--muted);
  background: linear-gradient(180deg, #fff, #fafbf8);
}

.empty-state svg {
  width: 32px;
  height: 32px;
  color: var(--line-strong);
}

.empty-state.hidden {
  display: none;
}

.diagnostic-panel {
  border-top: 1px solid var(--line);
  background: var(--warning-bg);
  padding: 12px 16px 16px;
}

.diagnostic-title {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--warning);
}

.diagnostic-title svg {
  width: 16px;
  height: 16px;
}

.diagnostic-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.diagnostic-item {
  border: 1px solid rgba(154, 91, 19, 0.24);
  border-radius: 6px;
  background: #fffaf0;
  padding: 10px;
  color: #3a2d1a;
  font-size: 13px;
  line-height: 1.5;
}

.diagnostic-item strong {
  color: var(--warning);
}

@media (max-width: 980px) {
  .app-shell {
    width: min(100vw - 20px, 760px);
    padding-top: 14px;
  }

  .topbar,
  .workspace {
    display: grid;
  }

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

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

  textarea {
    min-height: 260px;
  }
}

@media (max-width: 560px) {
  .settings-grid,
  .action-row {
    grid-template-columns: 1fr;
  }

  .result-header {
    display: grid;
  }

  .download-button {
    width: 100%;
  }

  h1 {
    font-size: 19px;
  }
}
