:root {
  color-scheme: light;
  --bg: #eef1f5;
  --surface: #ffffff;
  --surface-muted: #f5f7fa;
  --text: #1d2430;
  --muted: #647084;
  --line: #d7dde7;
  --primary: #16736f;
  --primary-dark: #0e5e5b;
  --accent: #b23a48;
  --gold: #b97813;
  --shadow: 0 18px 48px rgba(28, 39, 55, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(22, 115, 111, 0.16), transparent 34rem),
    linear-gradient(135deg, #eef1f5 0%, #f8fafc 52%, #edf0ed 100%);
  color: var(--text);
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
}

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

button {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  min-height: 36px;
  padding: 0 12px;
}

button:hover {
  border-color: #a9b4c3;
  background: #f8fafc;
}

.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

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

.app-shell {
  display: grid;
  grid-template-columns: minmax(320px, 390px) 1fr;
  gap: 18px;
  min-height: 100vh;
  padding: 18px;
}

.sidebar,
.editor-panel,
.translator-panel {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(215, 221, 231, 0.9);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 36px);
  padding: 16px;
  overflow: hidden;
}

.brand-row {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
}

.brand-mark {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, #16736f, #234f7a);
  color: #fff;
  font-weight: 800;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 20px;
  line-height: 1.2;
}

.brand-row p,
.eyebrow,
.save-state {
  color: var(--muted);
  font-size: 12px;
}

.search-row {
  display: grid;
  grid-template-columns: 1fr 40px;
  gap: 8px;
  margin-bottom: 10px;
}

.icon-button {
  padding: 0;
  font-size: 24px;
  line-height: 1;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  outline: none;
}

input,
select {
  min-height: 40px;
  padding: 0 12px;
}

textarea {
  min-height: 180px;
  resize: vertical;
  padding: 12px;
  line-height: 1.55;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(22, 115, 111, 0.13);
}

.toolbar-row,
.editor-actions,
.translator-actions,
.head-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.toolbar-row {
  margin-bottom: 12px;
}

.cloud-box {
  margin-bottom: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8fafc;
}

.cloud-box summary {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
  color: #334155;
  font-size: 13px;
  font-weight: 700;
  list-style: none;
}

.cloud-box summary::-webkit-details-marker {
  display: none;
}

.cloud-box label {
  margin-top: 10px;
}

.cloud-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.file-button {
  position: relative;
  display: inline-grid;
  place-items: center;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  cursor: pointer;
}

.file-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.tag-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.tag-chip {
  min-height: 28px;
  border-radius: 6px;
  padding: 0 8px;
  font-size: 12px;
}

.tag-chip.active {
  background: #e6f3f1;
  border-color: var(--primary);
  color: var(--primary-dark);
}

.prompt-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: auto;
  padding-right: 4px;
}

.prompt-item {
  display: grid;
  grid-template-columns: 1fr 38px;
  gap: 6px;
}

.prompt-main {
  display: block;
  height: auto;
  min-height: 72px;
  padding: 10px;
  text-align: left;
}

.prompt-main.active {
  border-color: var(--primary);
  background: #effaf8;
}

.prompt-title {
  display: block;
  font-weight: 700;
  margin-bottom: 5px;
}

.prompt-preview {
  display: -webkit-box;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.prompt-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}

.prompt-tags span {
  border-radius: 5px;
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 11px;
  padding: 2px 6px;
}

.prompt-star {
  padding: 0;
  font-size: 20px;
  color: var(--gold);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 0.82fr);
  gap: 18px;
  min-height: calc(100vh - 36px);
}

.editor-panel,
.translator-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px;
  min-width: 0;
}

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

h2 {
  font-size: 18px;
  line-height: 1.25;
}

label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  color: #334155;
  font-size: 13px;
  font-weight: 700;
}

.grow {
  flex: 1;
}

.grow textarea {
  min-height: 260px;
  height: 100%;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, minmax(54px, 1fr));
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
}

.segmented button {
  border: 0;
  border-radius: 0;
  min-height: 34px;
}

.segmented .active {
  background: var(--primary);
  color: white;
}

.provider-box {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8fafc;
}

.provider-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.provider-settings {
  display: none;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.provider-settings.visible {
  display: grid;
}

.provider-hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.translation-output {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfcfd;
  min-height: 170px;
  overflow: hidden;
}

.output-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.translation-text {
  white-space: pre-wrap;
  padding: 12px;
  line-height: 1.6;
}

@media (max-width: 1040px) {
  .app-shell,
  .workspace {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
    max-height: 48vh;
  }
}

@media (max-width: 620px) {
  .app-shell {
    padding: 10px;
    gap: 10px;
  }

  .sidebar,
  .editor-panel,
  .translator-panel {
    border-radius: 7px;
    box-shadow: 0 10px 28px rgba(28, 39, 55, 0.1);
  }

  .sidebar {
    max-height: none;
    padding: 12px;
  }

  .workspace {
    gap: 10px;
    min-height: auto;
  }

  .editor-panel,
  .translator-panel {
    padding: 12px;
  }

  .panel-head {
    flex-direction: column;
  }

  .head-actions,
  .editor-actions,
  .translator-actions {
    width: 100%;
  }

  .provider-row,
  .provider-settings,
  .cloud-actions {
    grid-template-columns: 1fr;
  }

  .head-actions button,
  .editor-actions button,
  .translator-actions button {
    flex: 1;
  }

  .grow textarea {
    min-height: 220px;
    height: 220px;
  }

  .translation-output {
    min-height: 150px;
  }
}
