:root {
  color-scheme: light;
  --bg: #f3f4f6;
  --panel: #ffffff;
  --panel-soft: #f8f8f9;
  --text: #202329;
  --muted: #68707c;
  --line: #d9dce2;
  --line-strong: #bfc4cd;
  --accent: #b5523d;
  --accent-dark: #91402f;
  --accent-soft: #f8e7e2;
  --warning: #9a5b13;
  --warning-bg: #fff5df;
  --danger: #b42318;
  --shadow: 0 16px 42px rgba(32, 35, 41, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  background: 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(181, 82, 61, 0.26);
  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;
}

.stealth-editor {
  position: relative;
  border: 1px solid transparent;
  border-radius: 6px;
  transition:
    border-color 140ms ease,
    background-color 140ms ease;
}

.stealth-editor #bankName {
  border-color: transparent;
  background: transparent;
  padding-right: 38px;
  cursor: default;
  transition:
    background-color 140ms ease,
    box-shadow 140ms ease;
}

.stealth-editor:hover,
.stealth-editor:focus-within {
  border-color: var(--line);
  background: var(--panel);
}

.stealth-editor:hover #bankName,
.stealth-editor:focus-within #bankName {
  background: var(--panel);
}

.stealth-editor.editing {
  border-color: var(--accent);
  background: var(--panel);
  box-shadow: 0 0 0 3px rgba(181, 82, 61, 0.14);
}

.stealth-editor.editing #bankName {
  cursor: text;
}

.stealth-edit-button {
  position: absolute;
  top: 50%;
  right: 5px;
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  transform: translateY(-50%);
  border: 0;
  border-left: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  opacity: 0;
  pointer-events: none;
  transition:
    color 140ms ease,
    opacity 140ms ease;
}

.stealth-editor:hover .stealth-edit-button,
.stealth-editor:focus-within .stealth-edit-button {
  opacity: 1;
  pointer-events: auto;
}

.stealth-edit-button:hover {
  color: var(--accent-dark);
}

.stealth-edit-button svg {
  width: 15px;
  height: 15px;
}

.field input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(181, 82, 61, 0.14);
}

.stealth-editor #bankName:focus {
  border-color: transparent;
  box-shadow: none;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(340px, 440px) minmax(0, 1fr);
  gap: 16px;
  align-items: stretch;
  min-height: calc(100vh - 130px);
}

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

.input-panel {
  display: flex;
  flex-direction: column;
  padding: 16px;
}

.result-panel {
  display: flex;
  flex-direction: column;
  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: #f0f1f3;
}

.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;
  flex: 1;
  gap: 10px;
}

textarea {
  width: 100%;
  height: 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: #fafafb;
  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;
  flex: 1;
  min-height: 0;
  overflow: auto;
}

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

thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  border-bottom: 1px solid var(--line-strong);
  background: #edf0f4;
  color: #292e36;
  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 14px 10px 10px;
}

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

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

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

.resizable-header {
  position: sticky;
  user-select: none;
}

.header-label {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.column-resizer {
  position: absolute;
  top: 0;
  right: -4px;
  z-index: 3;
  width: 9px;
  height: 100%;
  border: 0;
  background: transparent;
  cursor: col-resize;
  touch-action: none;
}

.column-resizer::after {
  position: absolute;
  top: 8px;
  right: 4px;
  bottom: 8px;
  width: 1px;
  background: var(--line-strong);
  content: "";
  opacity: 0.45;
}

.resizable-header:hover .column-resizer::after,
.column-resizer:hover::after {
  width: 2px;
  background: var(--accent);
  opacity: 1;
}

body.resizing-column,
body.resizing-column * {
  cursor: col-resize !important;
  user-select: none !important;
}

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

.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;
    min-height: 0;
  }

  .input-panel,
  .result-panel {
    min-height: 520px;
  }

  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;
  }
}
