* {
  box-sizing: border-box;
}

:root {
  --bg: #050506;
  --app: #0d0e10;
  --surface: #15161a;
  --surface-strong: #1c1d22;
  --surface-soft: #101114;
  --line: rgba(255, 255, 255, 0.11);
  --line-strong: rgba(226, 181, 91, 0.5);
  --text: #f6f0e3;
  --muted: #a9a294;
  --muted-strong: #d6cdbd;
  --gold: #e2b55b;
  --gold-strong: #ffd98a;
  --gold-deep: #a56d1f;
  --danger: #ff7a70;
  --danger-soft: rgba(255, 122, 112, 0.14);
  --success: #8bd8a8;
  --success-soft: rgba(139, 216, 168, 0.12);
  --shadow: 0 24px 62px rgba(0, 0, 0, 0.58);
  --gold-glow: 0 0 24px rgba(226, 181, 91, 0.18);
  --inner: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

html,
body {
  margin: 0;
  min-width: 410px;
  max-width: 410px;
  min-height: 640px;
  font-family: "Segoe UI", Arial, sans-serif;
  color: var(--text);
  background:
    linear-gradient(145deg, #040405 0%, #151515 48%, #070707 100%);
  letter-spacing: 0;
}

body {
  padding: 8px;
}

.app {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-areas:
    "hero"
    "composer"
    "metrics"
    "breakdown"
    "heatmap"
    "compare"
    "footer";
  gap: 10px;
  min-height: 624px;
  padding: 13px;
  border: 1px solid rgba(226, 181, 91, 0.28);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.018)),
    var(--app);
  box-shadow: var(--shadow), var(--gold-glow);
}

.app::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 5px;
  pointer-events: none;
  background: linear-gradient(90deg, transparent, var(--gold), var(--gold-strong), var(--gold), transparent);
  opacity: 0.9;
}

.app::after {
  content: "";
  position: absolute;
  inset: 5px 0 auto;
  height: 110px;
  pointer-events: none;
  background:
    linear-gradient(110deg, rgba(226, 181, 91, 0.16), transparent 46%),
    linear-gradient(250deg, rgba(255, 255, 255, 0.06), transparent 54%);
}

.ambient {
  display: none;
}

.hero,
.panel,
.footer-actions {
  position: relative;
  z-index: 1;
}

.hero {
  grid-area: hero;
  display: grid;
  grid-template-columns: 48px 1fr;
  align-items: center;
  column-gap: 11px;
  min-height: 58px;
  padding: 5px 3px 12px;
  border-bottom: 1px solid rgba(226, 181, 91, 0.18);
}

.hero-logo {
  width: 46px;
  height: 46px;
  border: 1px solid rgba(255, 217, 138, 0.55);
  border-radius: 8px;
  background:
    linear-gradient(145deg, rgba(255, 234, 183, 0.14), rgba(0, 0, 0, 0.1)),
    url("logo-gold.png") center center / cover no-repeat;
  filter: saturate(1.18) brightness(1.12) contrast(1.05);
  box-shadow:
    0 14px 26px rgba(0, 0, 0, 0.34),
    0 0 20px rgba(226, 181, 91, 0.18),
    var(--inner);
}

.hero h1 {
  margin: 0;
  color: var(--gold-strong);
  font-size: 20px;
  font-weight: 850;
  line-height: 1.08;
}

.hero p {
  grid-column: 2;
  margin: 3px 0 0;
  color: var(--muted-strong);
  font-size: 12px;
  font-weight: 650;
  line-height: 1.35;
}

.panel {
  min-width: 0;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.025)),
    var(--surface);
  box-shadow:
    0 14px 30px rgba(0, 0, 0, 0.28),
    var(--inner);
}

.composer-panel {
  grid-area: composer;
  display: grid;
  align-content: start;
  gap: 10px;
}

.composer-panel::before,
.metrics-panel::before {
  display: block;
  color: var(--gold-strong);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
}

.composer-panel::before {
  content: "Draft";
}

.metrics-panel::before {
  content: "Tone Score";
  margin-bottom: 8px;
}

.composer-shell {
  position: relative;
  min-height: 118px;
  border: 1px solid rgba(226, 181, 91, 0.24);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.018)),
    #0b0c0e;
  box-shadow:
    inset 0 1px 18px rgba(0, 0, 0, 0.34),
    0 0 0 3px rgba(226, 181, 91, 0.055);
}

.highlight-layer,
textarea {
  width: 100%;
  min-height: 118px;
  padding: 13px 14px;
  border: 0;
  border-radius: 8px;
  font: 500 14px/1.5 "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
}

.highlight-layer {
  position: absolute;
  inset: 0;
  overflow: hidden;
  color: transparent;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
  white-space: pre-wrap;
  word-break: break-word;
}

.highlight-layer mark {
  border-radius: 4px;
  box-shadow: 0 0 0 1px rgba(255, 122, 112, 0.24);
}

textarea {
  position: relative;
  resize: none;
  color: var(--text);
  background: transparent;
  outline: none;
}

textarea::placeholder {
  color: rgba(246, 240, 227, 0.42);
}

textarea.quote-preview {
  color: var(--gold-strong);
  font-weight: 760;
  text-align: center;
}

.wellbeing-row {
  display: flex;
  justify-content: flex-end;
  margin-top: -2px;
}

.quote-button {
  min-height: 30px;
  padding: 7px 10px;
  border: 1px solid rgba(139, 216, 168, 0.28);
  border-radius: 7px;
  color: var(--success);
  background:
    linear-gradient(180deg, rgba(139, 216, 168, 0.12), rgba(255, 255, 255, 0.025)),
    #101114;
  font-size: 11px;
  font-weight: 820;
  line-height: 1.1;
  box-shadow: var(--inner);
}

.quote-button:hover {
  color: #d8ffe5;
  border-color: rgba(139, 216, 168, 0.5);
  box-shadow:
    0 0 18px rgba(139, 216, 168, 0.16),
    var(--inner);
}

.action-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
}

button,
select {
  font: inherit;
  letter-spacing: 0;
}

button {
  appearance: none;
  border: 0;
  color: inherit;
  cursor: pointer;
  transition:
    transform 0.14s ease,
    box-shadow 0.18s ease,
    background 0.18s ease,
    border-color 0.18s ease,
    color 0.18s ease;
}

button:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid rgba(255, 217, 138, 0.52);
  outline-offset: 2px;
}

button:disabled {
  cursor: default;
  opacity: 0.66;
  transform: none;
}

button.is-loading {
  pointer-events: none;
}

button.is-loading::after {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-left: 7px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  vertical-align: -1px;
  animation: emotionalEchoSpin 0.72s linear infinite;
}

@keyframes emotionalEchoSpin {
  to {
    transform: rotate(360deg);
  }
}

.pill-button,
.mini-button,
.restore-button {
  min-height: 35px;
  padding: 8px 8px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 7px;
  color: var(--muted-strong);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.025)),
    #111216;
  font-size: 12px;
  font-weight: 760;
  line-height: 1.15;
  box-shadow: var(--inner);
}

.pill-button:hover,
.mini-button:hover,
.restore-button:hover {
  color: var(--gold-strong);
  border-color: rgba(255, 217, 138, 0.45);
  background:
    linear-gradient(180deg, rgba(226, 181, 91, 0.16), rgba(226, 181, 91, 0.06)),
    #15161a;
  box-shadow: var(--gold-glow), var(--inner);
}

.pill-button.active {
  color: #15110a;
  border-color: rgba(255, 217, 138, 0.72);
  background: linear-gradient(180deg, var(--gold-strong), #d19a3d);
  box-shadow:
    0 12px 22px rgba(226, 181, 91, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.52);
}

.rewrite-tools {
  padding: 11px;
  border: 1px solid rgba(226, 181, 91, 0.2);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(226, 181, 91, 0.095), rgba(255, 255, 255, 0.03)),
    #101114;
}

.rewrite-style-label {
  display: block;
  margin-bottom: 8px;
  color: var(--gold-strong);
  font-size: 12px;
  font-weight: 800;
}

.rewrite-tools-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  align-items: center;
}

.rewrite-style-select {
  appearance: none;
  width: 100%;
  min-height: 36px;
  padding: 8px 32px 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 7px;
  color: var(--text);
  background:
    linear-gradient(45deg, transparent 50%, var(--gold) 50%) calc(100% - 16px) 15px / 6px 6px no-repeat,
    linear-gradient(135deg, var(--gold) 50%, transparent 50%) calc(100% - 11px) 15px / 6px 6px no-repeat,
    #111216;
  font-size: 12px;
  font-weight: 680;
}

.rewrite-style-select option {
  color: #171717;
  background: #f8efd9;
}

.copy-button {
  grid-column: 1 / -1;
  width: 100%;
  min-width: 0;
  color: #15110a;
  border-color: rgba(255, 217, 138, 0.72);
  background: linear-gradient(180deg, var(--gold-strong), #d19a3d);
  box-shadow: 0 12px 22px rgba(226, 181, 91, 0.2);
}

.copy-button:hover {
  color: #15110a;
  border-color: rgba(255, 217, 138, 0.9);
  background: linear-gradient(180deg, #ffe3a7, #d99f43);
}

.trial-status {
  margin-top: 9px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.trial-status.trial-warning {
  color: var(--gold-strong);
}

.trial-status.trial-locked {
  color: var(--danger);
}

.metrics-panel {
  grid-area: metrics;
}

.scale-row,
.metric-row,
.section-heading,
.intensity-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.scale-row {
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}

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

#intensityMeter {
  flex: 1;
  height: 6px;
  accent-color: var(--gold);
}

#intensityValue,
.metric-row strong {
  min-width: 54px;
  padding: 4px 7px;
  border: 1px solid rgba(226, 181, 91, 0.2);
  border-radius: 7px;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(226, 181, 91, 0.12), rgba(255, 255, 255, 0.035)),
    #101114;
  font-size: 12px;
  font-weight: 800;
  text-align: right;
}

.metric-block + .metric-block {
  margin-top: 11px;
}

.metric-row {
  margin-bottom: 7px;
  color: var(--muted-strong);
  font-size: 12px;
  font-weight: 650;
}

.bar {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
}

.bar div {
  width: 0;
  height: 100%;
  border-radius: inherit;
  transition: width 0.25s ease;
}

.bar-blue div,
.bar-cyan div {
  background: linear-gradient(90deg, #735020, var(--gold-strong));
}

.bar-amber div {
  background: linear-gradient(90deg, var(--gold-strong), var(--danger));
}

.risk-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 31px;
  margin-top: 12px;
  padding: 7px 10px;
  border: 1px solid rgba(226, 181, 91, 0.22);
  border-radius: 7px;
  color: var(--gold-strong);
  background: rgba(226, 181, 91, 0.08);
  font-size: 12px;
  font-weight: 800;
}

.risk-badge[data-level="low"] {
  color: var(--success);
  border-color: rgba(139, 216, 168, 0.34);
  background: var(--success-soft);
}

.risk-badge[data-level="medium"] {
  color: var(--gold-strong);
  border-color: rgba(255, 217, 138, 0.42);
  background: rgba(226, 181, 91, 0.12);
}

.risk-badge[data-level="high"] {
  color: #ffb7b1;
  border-color: rgba(255, 122, 112, 0.44);
  background: var(--danger-soft);
}

.breakdown-panel {
  grid-area: breakdown;
}

.section-heading h2 {
  margin: 0;
  color: var(--gold-strong);
  font-size: 14px;
  font-weight: 850;
}

.section-heading span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}

.breakdown-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 11px;
}

.breakdown-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 43px;
  gap: 8px;
  padding: 8px 9px;
  border: 1px solid var(--category-border, var(--line));
  border-radius: 8px;
  color: var(--category-color, var(--muted-strong));
  background: var(--category-bg, rgba(255, 255, 255, 0.045));
  box-shadow: inset 4px 0 0 var(--category-color, rgba(226, 181, 91, 0.3));
  font-size: 12px;
  font-weight: 650;
}

.breakdown-item strong {
  color: var(--category-strong, var(--text));
  font-size: 12px;
  font-weight: 850;
}

.breakdown-item:nth-child(1) {
  --category-color: var(--gold);
  --category-strong: var(--gold-strong);
  --category-bg: rgba(226, 181, 91, 0.1);
  --category-border: rgba(226, 181, 91, 0.32);
}

.breakdown-item:nth-child(2) {
  --category-color: #ff8f86;
  --category-strong: #ffc2bd;
  --category-bg: rgba(255, 122, 112, 0.11);
  --category-border: rgba(255, 122, 112, 0.34);
}

.breakdown-item:nth-child(3) {
  --category-color: #c8a5ff;
  --category-strong: #e1ceff;
  --category-bg: rgba(180, 137, 255, 0.11);
  --category-border: rgba(180, 137, 255, 0.32);
}

.breakdown-item.toxicity-item {
  color: var(--toxicity-card-text, var(--muted-strong));
  border-color: var(--toxicity-card-border, var(--line));
  background: var(--toxicity-card-bg, rgba(255, 255, 255, 0.045));
}

.breakdown-item.toxicity-item span,
.breakdown-item.toxicity-item strong {
  color: inherit;
}

.heatmap-panel {
  grid-area: heatmap;
}

.results-copy,
.workplace-risk,
.suggestion-list {
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: var(--muted-strong);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.018)),
    #101114;
  font-size: 12px;
  line-height: 1.45;
}

.heatmap-panel .results-copy {
  margin-top: 11px;
}

.workplace-risk,
.suggestion-list {
  margin-top: 8px;
}

.risk-category-grid {
  display: grid;
  gap: 6px;
}

.risk-category-chip {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border: 1px solid var(--risk-chip-border, var(--line));
  border-radius: 7px;
  color: var(--risk-chip-text, var(--muted-strong));
  background: var(--risk-chip-bg, rgba(255, 255, 255, 0.035));
}

.risk-category-chip strong {
  color: var(--risk-chip-title, var(--text));
  font-size: 12px;
}

.risk-category-chip span {
  color: inherit;
  font-size: 11px;
  text-align: right;
}

.risk-category-chip[data-level="low"] {
  --risk-chip-bg: var(--success-soft);
  --risk-chip-border: rgba(139, 216, 168, 0.32);
  --risk-chip-title: var(--success);
  --risk-chip-text: #ccefd8;
}

.risk-category-chip[data-level="medium"] {
  --risk-chip-bg: rgba(226, 181, 91, 0.11);
  --risk-chip-border: rgba(255, 217, 138, 0.36);
  --risk-chip-title: var(--gold-strong);
  --risk-chip-text: #ead7ad;
}

.risk-category-chip[data-level="high"] {
  --risk-chip-bg: var(--danger-soft);
  --risk-chip-border: rgba(255, 122, 112, 0.38);
  --risk-chip-title: #ffb7b1;
  --risk-chip-text: #ffd3cf;
}

.match-chip {
  display: inline-flex;
  margin: 6px 6px 0 0;
  padding: 4px 8px;
  border: 1px solid rgba(255, 217, 138, 0.42);
  border-radius: 999px;
  color: var(--gold-strong);
  background: rgba(226, 181, 91, 0.11);
  font-size: 11px;
  font-weight: 800;
}

.compare-panel {
  grid-area: compare;
}

.compare-panel-hidden {
  display: none;
}

.compare-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 11px;
}

.compare-card {
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
}

.compare-card-accent {
  border-color: rgba(255, 217, 138, 0.42);
  background: rgba(226, 181, 91, 0.11);
}

.compare-label {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.compare-card strong {
  display: block;
  margin-top: 5px;
  color: var(--text);
  font-size: 22px;
  line-height: 1.05;
}

.compare-meta,
.compare-message {
  color: var(--muted-strong);
  font-size: 12px;
}

.compare-message {
  margin: 8px 2px 0;
  line-height: 1.42;
}

.footer-actions {
  grid-area: footer;
  display: grid;
  grid-template-columns: 1fr;
  align-items: center;
  gap: 8px;
}

.upgrade-button {
  width: 100%;
  min-height: 39px;
  padding: 9px 12px;
  border: 1px solid rgba(255, 217, 138, 0.75);
  border-radius: 8px;
  color: #15110a;
  background: linear-gradient(180deg, var(--gold-strong), #d19a3d);
  font-size: 13px;
  font-weight: 850;
  box-shadow:
    0 14px 26px rgba(226, 181, 91, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.restore-button {
  width: 100%;
}

.upgrade-note,
.local-stats {
  margin: -2px 2px 0;
  color: var(--muted);
  text-align: center;
  font-size: 11px;
  line-height: 1.35;
}

.upgrade-button:hover,
.mini-button:hover,
.pill-button:hover,
.restore-button:hover {
  transform: translateY(-1px);
}

.upgrade-button:disabled:hover,
.mini-button:disabled:hover,
.pill-button:disabled:hover,
.restore-button:disabled:hover {
  transform: none;
}
