:root {
  --bg: #f5f1e8;
  --paper: rgba(255, 251, 245, 0.94);
  --ink: #1d1d1b;
  --muted: #5d6158;
  --line: rgba(44, 58, 42, 0.14);
  --accent: #1d5c4f;
  --accent-strong: #114239;
  --warn: #9f3a2b;
  --ok: #23533d;
  --shadow: 0 20px 60px rgba(31, 41, 36, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(29, 92, 79, 0.16), transparent 28%),
    radial-gradient(circle at top right, rgba(175, 92, 45, 0.12), transparent 24%),
    linear-gradient(180deg, #f8f4ec 0%, #efe7d9 100%);
}

input,
textarea,
button {
  font: inherit;
}

.hidden {
  display: none !important;
}

.shell {
  width: min(980px, calc(100vw - 24px));
  margin: 18px auto 28px;
  display: grid;
  gap: 14px;
}

.remote-lite-shell {
  width: min(980px, calc(100vw - 24px));
}

.hero {
  padding: 12px 12px 0;
}

.hero h1 {
  margin: 0;
  font-family: "Georgia", "Times New Roman", serif;
  font-size: clamp(2rem, 3.6vw, 3.4rem);
  font-weight: 600;
  line-height: 0.98;
}

.remote-hero-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.status-panel,
.auth-panel,
.app-panel {
  padding: 16px;
}

.status-banner {
  padding: 12px 14px;
  border-radius: 14px;
  font-size: 0.95rem;
}

.status-banner.idle {
  background: rgba(29, 92, 79, 0.08);
  color: var(--accent-strong);
}

.status-banner.working {
  background: rgba(169, 111, 47, 0.12);
  color: #7b4d1d;
}

.status-banner.success {
  background: rgba(35, 83, 61, 0.12);
  color: var(--ok);
}

.status-banner.error {
  background: rgba(159, 58, 43, 0.12);
  color: var(--warn);
}

.auth-panel {
  display: grid;
  gap: 12px;
}

.login-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.field {
  display: grid;
  gap: 6px;
}

.field span {
  font-size: 0.76rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

input,
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid rgba(29, 92, 79, 0.18);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.86);
  color: var(--ink);
}

input:focus,
textarea:focus {
  outline: 2px solid rgba(29, 92, 79, 0.18);
  border-color: rgba(29, 92, 79, 0.4);
}

textarea {
  resize: vertical;
  line-height: 1.45;
  font-family: "SFMono-Regular", "Cascadia Code", "Menlo", monospace;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid rgba(29, 92, 79, 0.2);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--accent-strong);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: rgba(29, 92, 79, 0.42);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

.button.solid {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
  border-color: transparent;
  color: #f7f4ee;
}

.app-panel {
  display: grid;
  gap: 10px;
}

.remote-top-stack {
  display: grid;
  gap: 10px;
}

.remote-legref-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content;
  gap: 10px;
  align-items: end;
}

.remote-legref-field {
  min-width: 0;
}

.remote-inline-actions {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: max-content;
  gap: 8px;
  align-items: end;
  justify-content: end;
  white-space: nowrap;
}

.remote-textarea {
  min-height: 120px;
  font-size: 0.84rem;
}

.primary-textarea {
  min-height: 120px;
}

.remote-notes-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content;
  gap: 10px;
  align-items: start;
}

.remote-notes {
  min-height: 84px;
  font-size: 0.84rem;
}

.remote-side-actions {
  display: grid;
  gap: 8px;
  align-self: stretch;
}

.remote-side-actions .button {
  min-width: 132px;
}

.compact-summary,
.result-box {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.68);
  white-space: pre-wrap;
  line-height: 1.35;
  color: var(--muted);
}

.compact-summary {
  font-size: 0.88rem;
}

.compact-summary.is-empty {
  display: none;
}

.save-button {
  width: 100%;
}

.result-box {
  min-height: 96px;
  max-height: 220px;
  overflow: auto;
  font-family: "SFMono-Regular", "Cascadia Code", "Menlo", monospace;
  font-size: 0.84rem;
}

@media (max-width: 640px) {
  .shell {
    width: min(980px, calc(100vw - 16px));
    margin: 12px auto 20px;
  }

  .hero {
    padding: 4px 0 0;
  }

  .status-panel,
  .auth-panel,
  .app-panel {
    padding: 12px;
  }

  .login-row,
  .remote-legref-row,
  .remote-notes-row {
    grid-template-columns: 1fr;
  }

  .remote-hero-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .remote-inline-actions {
    justify-content: flex-start;
  }

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