:root {
  --page: #f3f5f4;
  --surface: #ffffff;
  --surface-soft: #f7f9f8;
  --ink: #18211e;
  --muted: #69736f;
  --line: #dce3e0;
  --brand: #176b5b;
  --brand-dark: #105447;
  --danger: #a33a32;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--page);
  font-family: Arial, "Microsoft YaHei", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

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

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  width: min(1200px, calc(100% - 40px));
  height: 64px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 19px;
  font-weight: 700;
  text-decoration: none;
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  color: #ffffff;
  background: var(--brand);
  border-radius: 8px;
  font-size: 16px;
}

.topbar p,
h1,
h2,
p {
  margin: 0;
}

.topbar p {
  color: var(--muted);
  font-size: 14px;
}

.app {
  width: min(1200px, calc(100% - 40px));
  margin: 0 auto;
  padding: 32px 0 48px;
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(300px, 0.9fr);
  gap: 24px;
  align-items: start;
}

.reader-panel,
.side-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 22px rgba(32, 47, 41, 0.05);
}

.reader-panel {
  padding: 30px;
}

.section-title,
.side-title,
.field-heading,
.range-heading,
.range-labels,
.storage-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.reader-title {
  align-items: flex-start;
  margin-bottom: 24px;
}

.eyebrow {
  display: block;
  margin-bottom: 7px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 700;
}

h1 {
  font-size: 30px;
  line-height: 1.25;
}

h2 {
  font-size: 19px;
  line-height: 1.3;
}

.section-title p {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.55;
}

.status {
  flex: 0 0 auto;
  max-width: 150px;
  padding: 7px 11px;
  color: var(--brand-dark);
  background: #eaf5f1;
  border: 1px solid #c6dfd7;
  border-radius: 999px;
  font-size: 13px;
  text-align: center;
}

.upload-box {
  min-height: 76px;
  margin-bottom: 22px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 13px;
  color: var(--ink);
  background: var(--surface-soft);
  border: 1px dashed #9cb2aa;
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease;
}

.upload-box:hover {
  background: #f0f6f3;
  border-color: var(--brand);
}

.upload-box input {
  display: none;
}

.upload-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  color: var(--brand);
  background: #e3f0ec;
  border-radius: 50%;
  font-size: 20px;
  font-weight: 700;
}

.upload-copy {
  display: grid;
  gap: 4px;
}

.upload-copy small,
.field-heading > span,
.range-labels,
.storage-line,
.empty-text {
  color: var(--muted);
  font-size: 13px;
}

.field-heading {
  margin-bottom: 9px;
}

.field-label,
.control-group > span {
  display: block;
  margin-bottom: 8px;
  color: #33413c;
  font-weight: 700;
}

.field-heading .field-label,
.range-heading span {
  margin: 0;
}

.text-box,
.translate-box,
.title-input,
select {
  width: 100%;
  color: var(--ink);
  background: #ffffff;
  border: 1px solid #cbd5d1;
  border-radius: 6px;
  outline: none;
}

.text-box,
.translate-box {
  padding: 15px;
  resize: vertical;
  line-height: 1.75;
}

.text-box {
  min-height: 360px;
}

.translate-box {
  min-height: 116px;
}

.text-box:focus,
.translate-box:focus,
.title-input:focus,
select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(23, 107, 91, 0.12);
}

.settings-grid {
  margin-top: 20px;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 22px;
}

select,
.title-input {
  height: 43px;
  padding: 0 12px;
}

.range-heading strong {
  min-width: 42px;
  padding: 3px 7px;
  color: var(--brand-dark);
  background: #eaf5f1;
  border-radius: 5px;
  font-size: 13px;
  text-align: center;
}

input[type="range"] {
  width: 100%;
  margin: 7px 0 3px;
  accent-color: var(--brand);
}

.reader-actions,
.translate-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.reader-actions {
  margin-top: 24px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

button {
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 700;
  transition: background 150ms ease, border-color 150ms ease;
}

.primary-button,
.save-button {
  color: #ffffff;
  background: var(--brand);
}

.primary-button:hover,
.save-button:hover {
  background: var(--brand-dark);
}

.secondary-button,
.small-button,
.icon-button {
  color: #35423e;
  background: #ffffff;
  border-color: #cbd5d1;
}

.secondary-button:hover,
.small-button:hover,
.icon-button:hover {
  background: var(--surface-soft);
  border-color: #9eada7;
}

button:disabled {
  color: #8b9692;
  background: #e9edeb;
  cursor: not-allowed;
}

.side-panel {
  overflow: hidden;
}

.side-section {
  padding: 24px;
}

.side-section + .side-section {
  border-top: 1px solid var(--line);
}

.side-title {
  align-items: flex-start;
  margin-bottom: 20px;
}

.icon-button {
  width: 38px;
  min-height: 38px;
  padding: 0;
  font-size: 20px;
}

.save-button {
  width: 100%;
  margin-top: 12px;
}

.storage-line {
  justify-content: flex-start;
  gap: 7px;
  margin: 18px 0 10px;
}

.connection-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  background: #82a39a;
  border-radius: 50%;
}

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

.document-item {
  padding: 11px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 6px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.document-title {
  font-weight: 700;
  overflow-wrap: anywhere;
}

.document-meta {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.small-button {
  min-height: 32px;
  padding: 0 8px;
  font-size: 12px;
}

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

.translate-actions {
  margin-top: 10px;
}

.translate-actions button {
  flex: 1;
}

.result-box {
  min-height: 110px;
  margin-top: 14px;
  padding: 14px;
  background: var(--surface-soft);
  border-left: 3px solid #8ca4ca;
}

.result-label {
  display: block;
  margin-bottom: 7px;
  color: #33413c;
  font-size: 13px;
  font-weight: 700;
}

.result-box p {
  color: var(--muted);
  line-height: 1.65;
}

@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .topbar-inner,
  .app {
    width: min(100% - 24px, 1200px);
  }

  .topbar p {
    display: none;
  }

  .app {
    padding: 16px 0 28px;
    gap: 14px;
  }

  .reader-panel,
  .side-section {
    padding: 18px;
  }

  .reader-title {
    flex-direction: column;
  }

  h1 {
    font-size: 26px;
  }

  .status {
    max-width: none;
  }

  .field-heading > span {
    display: none;
  }

  .text-box {
    min-height: 310px;
  }

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

  .reader-actions button {
    flex: 1 1 calc(50% - 5px);
  }

  .primary-button {
    flex-basis: 100% !important;
  }

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