:root {
  --bg: #ffffff;
  --surface: #f6f8f7;
  --panel: #ffffff;
  --ink: #17211f;
  --muted: #66736f;
  --line: #dce3e0;
  --line-strong: #c4cfca;
  --teal: #117c72;
  --teal-dark: #0c5f58;
  --teal-soft: #e3f2ef;
  --amber: #c48524;
  --amber-soft: #fff3dc;
  --danger-soft: #fff0ee;
  --shadow: 0 22px 60px rgba(20, 32, 29, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background:
    linear-gradient(180deg, #ffffff 0%, #f7faf9 56%, #f0f5f3 100%);
  color: var(--ink);
  line-height: 1.5;
}

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

a {
  color: inherit;
}

.site-header {
  width: min(1180px, calc(100% - 40px));
  margin: 22px auto 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  color: #ffffff;
  background: var(--teal-dark);
  box-shadow: inset 0 -10px 18px rgba(255, 255, 255, 0.1);
}

.language-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.82);
}

.language-nav a {
  min-height: 34px;
  padding: 7px 10px;
  border-radius: 7px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.language-nav a.active {
  color: var(--teal-dark);
  background: var(--teal-soft);
}

.app-frame {
  width: min(1180px, calc(100% - 40px));
  margin: 42px auto 46px;
}

.title-row {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 36px;
  margin-bottom: 22px;
}

.title-row h1 {
  margin: 0;
  max-width: 720px;
  font-size: 44px;
  line-height: 1.06;
  font-weight: 850;
  letter-spacing: 0;
}

.title-row p {
  max-width: 720px;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 17px;
}

.privacy-chip {
  flex: 0 0 auto;
  max-width: 280px;
  padding: 11px 14px;
  border: 1px solid #b9ddd7;
  border-radius: 8px;
  color: var(--teal-dark);
  background: var(--teal-soft);
  font-size: 13px;
  font-weight: 800;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.03fr) minmax(360px, 0.97fr);
  gap: 20px;
  align-items: start;
}

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

.input-panel,
.output-panel {
  padding: 20px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.panel-heading h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.field span,
.field-group legend,
.small-label,
.analysis-block span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

textarea,
input,
select {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--ink);
  background: #ffffff;
  outline: none;
}

textarea {
  min-height: 88px;
  resize: vertical;
  padding: 12px 13px;
}

input,
select {
  min-height: 42px;
  padding: 8px 11px;
}

textarea:focus,
input:focus,
select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(17, 124, 114, 0.14);
}

.control-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-items: start;
  margin-bottom: 14px;
}

.field-group {
  grid-column: 1 / -1;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.field-group legend {
  margin-bottom: 8px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(5, minmax(88px, 1fr));
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  overflow-x: auto;
}

.segmented button,
.ghost-button,
.copy-button,
.primary-button,
.secondary-button {
  border: 0;
  border-radius: 7px;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0;
  cursor: pointer;
}

.segmented button {
  min-height: 34px;
  padding: 7px 6px;
  color: var(--muted);
  background: transparent;
  white-space: nowrap;
}

.segmented button.selected {
  color: var(--teal-dark);
  background: #ffffff;
  box-shadow: 0 1px 4px rgba(20, 32, 29, 0.12);
}

.ghost-button,
.copy-button,
.secondary-button {
  min-height: 38px;
  padding: 9px 12px;
  color: var(--teal-dark);
  background: var(--teal-soft);
}

.primary-button {
  min-height: 44px;
  padding: 10px 16px;
  color: #ffffff;
  background: var(--teal);
}

.primary-button:hover {
  background: var(--teal-dark);
}

.toggle-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 4px 0 16px;
}

.toggle-row label {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  min-height: 44px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--surface);
  font-size: 13px;
  font-weight: 800;
}

.toggle-row input {
  width: 16px;
  height: 16px;
  min-height: 16px;
  margin-top: 2px;
  accent-color: var(--teal);
}

.button-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.reply-box {
  min-height: 194px;
  padding: 18px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: #101816;
  background: linear-gradient(180deg, #ffffff 0%, #fbfcfc 100%);
  white-space: pre-wrap;
}

.alternate-box {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid #ead1a5;
  border-radius: 8px;
  background: var(--amber-soft);
}

.alternate-box p {
  margin: 6px 0 0;
  color: #3b2b14;
}

.analysis-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.analysis-block {
  min-height: 80px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.analysis-block strong {
  display: block;
  margin-top: 8px;
  font-size: 15px;
  line-height: 1.25;
}

.risk-panel {
  margin-top: 14px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.risk-panel h3 {
  margin: 0 0 8px;
  font-size: 16px;
}

.risk-panel ul {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.risk-panel li {
  padding: 9px 10px;
  border-radius: 7px;
  color: #4d3213;
  background: var(--amber-soft);
  font-size: 13px;
  font-weight: 700;
}

.resource-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  margin-top: 20px;
  padding: 14px 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.resource-strip a {
  color: var(--teal-dark);
  text-decoration: none;
}

@media (max-width: 1020px) {
  .site-header,
  .title-row {
    align-items: flex-start;
  }

  .title-row {
    display: grid;
  }

  .privacy-chip {
    max-width: none;
  }

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

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

  .field-group {
    grid-column: 1 / -1;
  }
}

@media (max-width: 720px) {
  .site-header,
  .app-frame {
    width: min(100% - 24px, 1180px);
  }

  .site-header {
    display: grid;
    gap: 14px;
  }

  .language-nav {
    width: 100%;
    overflow-x: auto;
  }

  .app-frame {
    margin-top: 28px;
  }

  .title-row h1 {
    font-size: 32px;
  }

  .title-row p {
    font-size: 15px;
  }

  .input-panel,
  .output-panel {
    padding: 14px;
  }

  .control-grid,
  .toggle-row,
  .analysis-grid {
    grid-template-columns: 1fr;
  }

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

  .segmented button {
    min-height: 38px;
    white-space: normal;
  }

  .button-row {
    display: grid;
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: no-preference) {
  button,
  a,
  textarea,
  input,
  select {
    transition: border-color 160ms ease, background-color 160ms ease, color 160ms ease, box-shadow 160ms ease;
  }
}
