:root {
  color-scheme: light;
  --bg: #eef2ee;
  --panel: #ffffff;
  --panel-soft: #f7faf7;
  --ink: #17201d;
  --muted: #63716a;
  --line: #d6ded8;
  --line-strong: #b9c6be;
  --jade: #0f6a58;
  --jade-dark: #0a4038;
  --amber: #bf8b35;
  --amber-soft: #f2dfb8;
  --danger: #a43c35;
  --shadow: 0 16px 40px rgba(24, 36, 32, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  padding: 18px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1480px;
  margin: 0 auto 16px;
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(15, 106, 88, 0.28);
  border-radius: 8px;
  background: #ffffff;
  color: var(--jade-dark);
  font-size: 24px;
  font-weight: 800;
  box-shadow: var(--shadow);
}

h1,
h2,
p {
  margin: 0;
}

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

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

.brand p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(360px, 480px) minmax(380px, 1fr);
  gap: 16px;
  max-width: 1480px;
  margin: 0 auto;
  align-items: start;
}

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

.settings-panel,
.tool-panel,
.results-panel {
  min-width: 0;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 54px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.form-grid,
.tool-form {
  display: grid;
  gap: 14px;
  padding: 16px;
}

label {
  display: grid;
  gap: 7px;
  min-width: 0;
}

label span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.key-help {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.key-help a {
  color: var(--jade-dark);
  font-weight: 800;
  text-decoration: none;
}

.key-help a:hover {
  text-decoration: underline;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #ffffff;
  color: var(--ink);
  outline: none;
  transition:
    border-color 0.16s ease,
    box-shadow 0.16s ease;
}

input,
select {
  height: 42px;
  padding: 0 11px;
}

textarea {
  resize: vertical;
  min-height: 104px;
  padding: 11px;
  line-height: 1.45;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--jade);
  box-shadow: 0 0 0 3px rgba(15, 106, 88, 0.14);
}

input[readonly] {
  background: #f3f6f4;
  color: var(--jade-dark);
}

.password-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 58px;
  gap: 8px;
}

.icon-button,
.secondary-button,
.primary-button,
.tab {
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #ffffff;
  color: var(--ink);
}

.icon-button {
  height: 42px;
  padding: 0 8px;
  color: var(--jade-dark);
  font-size: 12px;
  font-weight: 700;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.check-row input {
  width: 16px;
  height: 16px;
}

.check-row span {
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 16px 16px 0;
}

.tab {
  height: 40px;
  font-weight: 800;
}

.tab.is-active {
  border-color: rgba(15, 106, 88, 0.28);
  background: var(--jade-dark);
  color: #ffffff;
}

.tool-form.is-hidden {
  display: none;
}

.inline-grid {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 12px;
}

.primary-button {
  height: 46px;
  border-color: var(--jade-dark);
  background: var(--jade-dark);
  color: #ffffff;
  font-weight: 800;
}

.primary-button:disabled,
.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.56;
}

.secondary-button {
  min-height: 36px;
  padding: 0 12px;
  color: var(--jade-dark);
  font-size: 13px;
  font-weight: 700;
}

.result-heading {
  align-items: center;
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.message {
  margin: 16px 16px 0;
  border: 1px solid rgba(164, 60, 53, 0.22);
  border-radius: 7px;
  background: #fff5f3;
  color: var(--danger);
  padding: 11px 12px;
  font-size: 13px;
  line-height: 1.45;
  word-break: break-word;
}

.message.is-ok {
  border-color: rgba(15, 106, 88, 0.22);
  background: #f0faf5;
  color: var(--jade-dark);
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  padding: 16px;
}

.empty-state {
  grid-column: 1 / -1;
  display: grid;
  place-items: center;
  min-height: 360px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 14px;
}

.result-item {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.result-image-frame {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef2ee;
  aspect-ratio: 1 / 1;
}

.result-image-frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.result-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.result-meta span {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-meta a {
  flex: 0 0 auto;
  border: 1px solid rgba(15, 106, 88, 0.24);
  border-radius: 7px;
  color: var(--jade-dark);
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  }

  .results-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding: 12px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

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

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

  .panel-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .result-actions {
    justify-content: flex-start;
  }
}
