:root {
  color-scheme: light;
  --canvas: #ffffff;
  --surface: #f7f7f8;
  --surface-soft: #fbfbfc;
  --ink: #111111;
  --charcoal: #2c2c2c;
  --slate: #62666d;
  --steel: #7a7f89;
  --hairline: #dedfe3;
  --hairline-soft: #eceef2;
  --brand-coral: #ff5c45;
  --brand-magenta: #d83eff;
  --brand-blue: #2168f3;
  --brand-purple: #6e45ff;
  --success-bg: #e8f8ee;
  --success-text: #12652d;
  --error: #d45656;
  --warning-bg: #fff5e6;
  --warning-text: #8a4b00;
  --shadow-card: rgba(0, 0, 0, 0.08) 0 4px 6px 0;
  --shadow-soft: rgba(0, 0, 0, 0.04) 0 1px 2px 0;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-hero: 32px;
  --radius-full: 9999px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  background:
    radial-gradient(circle at 12% 8%, rgba(255, 92, 69, 0.12), transparent 30%),
    radial-gradient(circle at 88% 16%, rgba(33, 104, 243, 0.11), transparent 28%),
    var(--canvas);
  color: var(--ink);
  font-family: "DM Sans", Inter, "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

.app-shell {
  width: min(1280px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 0 32px 48px;
}

.top-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 64px;
  padding: 14px 0;
  border-bottom: 0;
  background: transparent;
  backdrop-filter: none;
}

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

.top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.main-content {
  display: grid;
  gap: 24px;
  padding-top: 24px;
}

.notice,
.settings-panel,
.translate-panel {
  border: 1px solid var(--hairline);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow-soft);
}

.notice {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  border-radius: var(--radius-xl);
  padding: 16px 18px;
  color: var(--charcoal);
  font-size: 14px;
}

.notice strong {
  color: var(--ink);
  font-weight: 700;
}

.icon-button {
  display: inline-grid;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-full);
  background: var(--canvas);
  color: var(--ink);
  font-size: 20px;
  line-height: 1;
}

.settings-panel {
  border-radius: var(--radius-xl);
  padding: 24px;
}

.section-heading,
.panel-head,
.action-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.section-heading {
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--steel);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  color: var(--ink);
  font-weight: 600;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(24px, 4vw, 40px);
  line-height: 1.18;
}

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

.settings-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.field,
.switch-field {
  display: grid;
  gap: 8px;
  min-width: 0;
  color: var(--charcoal);
  font-size: 14px;
  font-weight: 500;
}

.field > span,
.fieldset legend {
  color: var(--charcoal);
}

.text-input,
.text-area,
.output-box {
  width: 100%;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  background: var(--canvas);
  color: var(--ink);
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.text-input {
  min-height: 44px;
  padding: 10px 14px;
}

.text-input:focus,
.text-area:focus {
  border-color: var(--brand-blue);
  box-shadow: 0 0 0 3px rgba(33, 104, 243, 0.12);
}

.text-input::placeholder,
.text-area::placeholder,
.output-box.is-empty {
  color: var(--steel);
}

.custom-language-field {
  grid-column: span 2;
}

.fieldset {
  margin: 0;
  padding: 0;
  border: 0;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: 100%;
  min-height: 44px;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-full);
  background: var(--surface);
}

.segmented-control label {
  display: grid;
  place-items: center;
  min-width: 0;
  border-radius: var(--radius-full);
  color: var(--steel);
  font-size: 14px;
  font-weight: 600;
}

.segmented-control input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented-control label:has(input:checked) {
  background: var(--ink);
  color: var(--canvas);
}

.switch-field {
  grid-template-columns: auto 1fr;
  align-items: center;
  align-self: end;
  min-height: 44px;
  color: var(--charcoal);
}

.switch-field input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch-track {
  position: relative;
  width: 48px;
  height: 28px;
  border-radius: var(--radius-full);
  background: var(--hairline);
  transition: background 160ms ease;
}

.switch-track::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: var(--radius-full);
  background: var(--canvas);
  box-shadow: var(--shadow-card);
  content: "";
  transition: transform 160ms ease;
}

.switch-field input:checked + .switch-track {
  background: var(--ink);
}

.switch-field input:checked + .switch-track::after {
  transform: translateX(20px);
}

.translator-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
  align-items: start;
}

.translate-panel {
  display: grid;
  gap: 18px;
  min-width: 0;
  border-radius: var(--radius-xl);
  padding: 22px;
}

.text-area,
.output-box {
  min-height: 280px;
  overflow: hidden;
  resize: none;
  padding: 18px;
  font-size: 18px;
  line-height: 1.55;
}

.output-box {
  white-space: pre-wrap;
  word-break: break-word;
}

.output-box.is-empty::before {
  content: attr(data-placeholder);
}

.button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: var(--radius-full);
  padding: 10px 22px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  text-decoration: none;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease, opacity 160ms ease;
}

.button-primary {
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--canvas);
}

.button-primary:disabled {
  border-color: var(--hairline);
  background: var(--hairline);
  color: var(--steel);
}

.button-secondary {
  border: 1px solid var(--ink);
  background: transparent;
  color: var(--ink);
}

.button-tertiary {
  border: 1px solid var(--hairline);
  background: var(--canvas);
  color: var(--ink);
}

.button.compact {
  min-height: 36px;
  padding: 8px 16px;
}

.action-row {
  position: sticky;
  bottom: 0;
  z-index: 10;
  margin-top: 2px;
  padding: 18px 0;
  border-top: 1px solid var(--hairline-soft);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(18px);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 899px) {
  .app-shell {
    padding: 0 20px 32px;
  }

  .top-bar,
  .section-heading,
  .panel-head,
  .action-row {
    align-items: stretch;
  }

  .top-bar {
    position: static;
    flex-direction: column;
  }

  .top-actions,
  .section-heading,
  .panel-head,
  .action-row {
    flex-wrap: wrap;
  }

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

  .custom-language-field {
    grid-column: auto;
  }

  .button,
  .button.compact,
  .icon-button,
  .text-input {
    min-height: 44px;
  }

  .text-area,
  .output-box {
    min-height: 220px;
    font-size: 16px;
  }
}

@media (max-width: 520px) {
  .app-shell {
    padding-inline: 14px;
  }

  .notice,
  .settings-panel,
  .translate-panel {
    border-radius: var(--radius-lg);
  }

  .notice {
    align-items: stretch;
  }

  .settings-panel,
  .translate-panel {
    padding: 18px;
  }

  .top-actions,
  .action-row,
  .button {
    width: 100%;
  }

  .top-actions .button {
    flex: 1 1 auto;
  }
}
