:root {
  --bg: #0f1713;
  --panel: #18221c;
  --panel-strong: #213127;
  --border: #31443a;
  --text: #ecf3ee;
  --muted: #a8b8ad;
  --accent: #355e3b;
  --accent-dark: #24452a;
  --button-soft: #26352d;
  --success: #78b488;
  --danger: #e18787;
  --danger-soft: #3a2525;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(120, 180, 136, 0.15), transparent 30%),
    linear-gradient(180deg, #162119 0%, var(--bg) 100%);
  color: var(--text);
}

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

.app-shell,
.auth-shell {
  min-height: 100vh;
}

.auth-shell {
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.auth-card,
.panel,
.sidebar-card {
  background: rgba(24, 34, 28, 0.96);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.28);
}

.auth-card {
  width: min(100%, 28rem);
  padding: 1.5rem;
}

.app-shell {
  display: grid;
  gap: 0.75rem;
  padding: 0.75rem;
}

.sidebar-card,
.panel {
  padding: 0.85rem;
}

.sidebar-header,
.panel-header,
.action-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.55rem;
}

.workspace,
.stack,
.session-list,
.history-list,
.field-grid {
  display: grid;
  gap: 0.7rem;
}

.field {
  display: grid;
  gap: 0.3rem;
}

.field span,
.template-preview label,
.history-language label {
  font-size: 0.92rem;
  font-weight: 700;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.75rem 0.9rem;
  background: #101713;
  color: var(--text);
}

input::placeholder,
textarea::placeholder {
  color: #8ea193;
}

textarea {
  resize: vertical;
}

button {
  cursor: pointer;
  border: 0;
  border-radius: 999px;
  padding: 0.7rem 1rem;
  min-height: 44px;
}

.primary-button {
  background: var(--accent);
  color: white;
  font-weight: 700;
}

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

.secondary-button,
.ghost-button {
  background: var(--button-soft);
  color: var(--text);
}

.ghost-button {
  border: 1px solid var(--border);
}

.full-width {
  width: 100%;
}

.muted {
  color: var(--muted);
  margin: 0.05rem 0 0;
  line-height: 1.3;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 1.35rem;
  line-height: 1.1;
}

h2 {
  font-size: 1.08rem;
  line-height: 1.15;
}

.session-link {
  display: grid;
  gap: 0.18rem;
  text-decoration: none;
  color: inherit;
  padding: 0.65rem;
  border-radius: 14px;
  min-width: 0;
}

.accordion-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  text-align: left;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.75rem 0.9rem;
}

.accordion-icon {
  font-size: 1.1rem;
  color: var(--muted);
}

.accordion-content {
  margin-top: 0.65rem;
}

.accordion-toolbar {
  justify-content: flex-end;
  margin-bottom: 0.2rem;
}

.sessions-accordion-list {
  max-height: 42vh;
  overflow-y: auto;
  padding-right: 0.15rem;
}

.session-card {
  position: relative;
  border-radius: 14px;
  background: #1a241e;
  border: 1px solid transparent;
  padding-right: 3.25rem;
}

.session-card.active {
  border-color: var(--accent);
  background: #223128;
}

.session-delete-form {
  position: absolute;
  top: 0.55rem;
  right: 0.55rem;
}

.delete-button {
  min-height: 40px;
  width: 40px;
  padding: 0;
  border-radius: 999px;
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid rgba(165, 80, 80, 0.2);
}

.delete-button:hover {
  background: #4a2f2f;
}

.message-bubble {
  border-radius: 18px;
  padding: 0.75rem;
  border: 1px solid var(--border);
}

.message-bubble.customer {
  background: #121a15;
}

.message-bubble.operator {
  background: #1f2d24;
}

.message-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.45rem;
}

.history-language p,
.template-preview p,
.empty-state,
.hint-card,
.alert,
.detected-address-value {
  margin: 0;
}

.spanish-block {
  display: none;
}

.show-bilingual .spanish-block {
  display: block;
}

.template-preview,
.hint-card,
.alert,
.translation-summary,
.detected-address {
  padding: 0.7rem 0.85rem;
  border-radius: 14px;
}

.template-preview,
.hint-card,
.translation-summary,
.detected-address {
  background: var(--panel-strong);
}

.translation-summary,
.detected-address {
  display: grid;
  gap: 0.3rem;
}

.compact-panel {
  gap: 0.5rem;
}

.compact-panel .panel-header {
  justify-content: flex-start;
  margin-bottom: -0.15rem;
}

.detected-address-value {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.65rem 0.8rem;
  background: #101713;
  word-break: break-word;
}

.alert {
  background: #3b2525;
  color: #ffb3b3;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.92rem;
}

.toggle input {
  width: auto;
}

.empty-dashboard {
  min-height: 40vh;
  display: grid;
  place-items: center;
  text-align: center;
}

.copy-button.copied {
  background: #d8f0e2;
  color: var(--success);
}

.sidebar-card {
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
}

.sidebar-card .sidebar-header {
  margin-bottom: 0.55rem;
}

.sidebar-card .sidebar-header > div {
  display: grid;
  gap: 0.08rem;
}

.sidebar-card .sidebar-header h1,
.auth-card h1 {
  font-size: 1.1rem;
  letter-spacing: 0.01em;
}

.sidebar-card .full-width {
  margin-top: 0.1rem;
}

.session-panel {
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
}

.session-panel .panel-header {
  margin-bottom: 0.2rem;
}

.session-panel .panel-header > div {
  display: grid;
  gap: 0.08rem;
}

.session-panel .field-grid {
  gap: 0.55rem;
}

.session-panel .hint-card {
  margin-top: 0.1rem;
}

.compact-panel textarea#incoming-text {
  margin-top: -0.05rem;
}

.compact-panel .action-row {
  margin-top: -0.05rem;
}

.sticky-panel .panel-header {
  margin-bottom: 0.05rem;
}

.sticky-panel .field-grid {
  gap: 0.55rem;
}

.sticky-panel .template-preview {
  margin-top: 0.1rem;
}

.sticky-panel .action-row {
  margin-top: -0.05rem;
}

.sticky-panel .field:last-of-type {
  margin-top: 0.05rem;
}

@media (min-width: 960px) {
  .app-shell {
    grid-template-columns: 320px minmax(0, 1fr);
    align-items: start;
  }

  .workspace {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .session-panel,
  .sticky-panel,
  .sessions-panel,
  .panel:last-child {
    grid-column: 1 / -1;
  }

  .field-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .field.wide {
    grid-column: span 3;
  }
}
