:root {
  --bg: #faf8f5;
  --bg-2: #f3efe9;
  --text: #2c2622;
  --text-dim: #8a7e73;
  --accent: #b3541e;
  --accent-hover: #9a4818;
  --accent-soft: #f7ece0;
  --danger: #c0392b;
  --border: #e6dfd5;
  --radius: 8px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #1f1b18;
    --bg-2: #28231f;
    --text: #e8e2db;
    --text-dim: #9b8f84;
    --accent: #d9874c;
    --accent-hover: #e09a60;
    --accent-soft: #3a2c1f;
    --danger: #e06c5a;
    --border: #3a322d;
  }
}

:root[data-theme="light"] {
  --bg: #faf8f5;
  --bg-2: #f3efe9;
  --text: #2c2622;
  --text-dim: #8a7e73;
  --accent: #b3541e;
  --accent-hover: #9a4818;
  --accent-soft: #f7ece0;
  --danger: #c0392b;
  --border: #e6dfd5;
}

:root[data-theme="dark"] {
  --bg: #1f1b18;
  --bg-2: #28231f;
  --text: #e8e2db;
  --text-dim: #9b8f84;
  --accent: #d9874c;
  --accent-hover: #e09a60;
  --accent-soft: #3a2c1f;
  --danger: #e06c5a;
  --border: #3a322d;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  overflow-x: hidden;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
    sans-serif;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 24px;
}

.site-header {
  padding: 14px 0;
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand-mark {
  color: var(--accent);
  font-weight: 800;
}

.tagline {
  margin: 0;
  color: var(--text-dim);
  font-size: 13px;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.theme-toggle:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}

.theme-icon {
  width: 18px;
  height: 18px;
}

.star-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 10px 0 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  transition: border-color 0.15s, background 0.15s;
}

.star-btn:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.star-icon {
  width: 15px;
  height: 15px;
  color: var(--text-dim);
  transition: color 0.15s;
}

.star-btn:hover .star-icon {
  color: var(--accent);
}

.star-label {
  white-space: nowrap;
}

.star-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--bg-2);
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.star-btn:hover .star-count {
  background: var(--bg);
  color: var(--text);
}

.layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 32px;
  padding-top: 20px;
  flex: 1;
}

@media (max-width: 640px) {
  .tagline {
    order: 1;
    width: 100%;
  }
}

@media (max-width: 860px) {
  .layout {
    grid-template-columns: 1fr;
    gap: 24px;
  }
}

.workspace,
.history {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.workspace {
  gap: 16px;
}

.drop-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 36px 20px;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
}

.drop-zone:hover,
.drop-zone:focus-visible {
  border-color: var(--accent);
  background: var(--accent-soft);
  outline: none;
}

.drop-zone.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.drop-icon {
  width: 36px;
  height: 36px;
  color: var(--text-dim);
}

.drop-title {
  margin: 0;
  font-weight: 600;
  font-size: 15px;
}

.drop-hint {
  margin: 0;
  color: var(--text-dim);
  font-size: 13px;
}

.preview-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.preview-wrap img {
  max-width: 100%;
  max-height: 280px;
  border-radius: var(--radius);
  object-fit: contain;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 180px;
}

.field-label {
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

select,
textarea {
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 12px;
  max-width: 100%;
}

select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24'><path fill='none' stroke='%238a7e73' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round' d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  cursor: pointer;
}

select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
}

select:hover {
  border-color: var(--text-dim);
}

select option {
  background: var(--bg);
  color: var(--text);
}

select option:checked,
select option:hover,
select option:focus {
  background-color: var(--accent-soft);
  color: var(--text);
}

textarea {
  resize: vertical;
  width: 100%;
}

.actions {
  display: flex;
  gap: 8px;
}

.btn {
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

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

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

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px;
}

.link-btn:hover {
  color: var(--accent-hover);
}

.link-btn.danger {
  color: var(--danger);
}

.link-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.progress {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.progress-bar {
  height: 6px;
  border-radius: 3px;
  background: var(--bg-2);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.2s ease;
}

.progress-text {
  margin: 0;
  font-size: 13px;
  color: var(--text-dim);
}

.result-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.history {
  gap: 14px;
}

.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.history-head h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
}

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.history-item {
  display: flex;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s;
}

.history-item:hover {
  background: var(--bg-2);
}

.history-thumb {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
}

.history-thumb.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 11px;
  background: var(--bg-2);
}

.history-meta {
  display: flex;
  flex-direction: column;
  gap: 1px;
  flex: 1;
  min-width: 0;
}

.history-time {
  font-size: 12px;
  color: var(--text-dim);
}

.history-lang {
  font-size: 10px;
  color: var(--accent);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.history-preview {
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-delete {
  align-self: flex-start;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 18px;
  padding: 0 4px;
  line-height: 1;
  opacity: 0.6;
  transition: color 0.15s, opacity 0.15s;
}

.history-item:hover .history-delete {
  opacity: 1;
}

.history-delete:hover {
  color: var(--danger);
}

.history-empty {
  color: var(--text-dim);
  font-size: 13px;
  text-align: center;
  padding: 20px 8px;
}

.site-footer {
  padding: 16px 0;
  color: var(--text-dim);
  font-size: 12px;
  text-align: center;
}

.site-footer p {
  margin: 0;
}

.site-footer .copyright {
  margin-top: 6px;
}

.site-footer .copyright a {
  color: var(--text-dim);
  text-decoration: none;
}

.site-footer .copyright a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.hidden {
  display: none !important;
}

.update-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 24px;
  background: var(--accent);
  color: white;
  animation: slide-down 0.25s ease;
}

@keyframes slide-down {
  from {
    transform: translateY(-100%);
  }
  to {
    transform: translateY(0);
  }
}

.update-text {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
}

.update-btn {
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid white;
  background: white;
  color: var(--accent);
  cursor: pointer;
}

.update-btn:hover {
  background: rgba(255, 255, 255, 0.9);
}

.update-close {
  background: none;
  border: none;
  color: white;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
  opacity: 0.85;
}

.update-close:hover {
  opacity: 1;
}