:root {
  --bg: #f4efe3;
  --surface: rgba(255, 252, 247, 0.9);
  --surface-strong: #ffffff;
  --ink: #2e2619;
  --ink-soft: #645740;
  --accent: #0d8f8b;
  --accent-strong: #066766;
  --line: rgba(60, 45, 20, 0.15);
  --warn: #bb3d2f;
  --ok: #1f7a54;
  --shadow: 0 18px 40px rgba(43, 29, 8, 0.12);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Syne", "Segoe UI", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 10% 10%, #e7dac4 0%, transparent 42%),
    radial-gradient(circle at 90% 0%, #e0f4ef 0%, transparent 46%),
    var(--bg);
}

.backdrop {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    -45deg,
    transparent 0,
    transparent 20px,
    rgba(21, 143, 140, 0.04) 20px,
    rgba(21, 143, 140, 0.04) 24px
  );
}

.shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  gap: 1rem;
  padding: 1rem;
}

.control-dock,
.studio {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  border-radius: 16px;
  padding: 1rem;
}

h1,
h2,
h3 {
  margin: 0;
}

h1 {
  font-size: 1.5rem;
  letter-spacing: 0.03em;
}

h2 {
  font-size: 1.25rem;
}

h3 {
  font-size: 1.05rem;
  margin-bottom: 0.75rem;
}

p,
label,
input,
textarea,
button,
th,
td,
pre {
  font-family: "IBM Plex Mono", "SFMono-Regular", monospace;
}

.muted {
  color: var(--ink-soft);
  margin: 0.45rem 0 0.9rem;
  font-size: 0.85rem;
}

.hint {
  min-height: 1.2rem;
  margin: 0.6rem 0 0;
  color: var(--ink-soft);
  font-size: 0.78rem;
}

.global-message {
  min-height: 1.2rem;
  margin: 0;
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.global-message.error {
  color: var(--warn);
}

.global-message.success {
  color: var(--ok);
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.7rem;
}

.doc-grid {
  margin-bottom: 0.7rem;
}

label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.75rem;
  color: var(--ink-soft);
}

input,
textarea {
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface-strong);
  color: var(--ink);
  padding: 0.6rem 0.65rem;
  font-size: 0.8rem;
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus {
  outline: 2px solid rgba(13, 143, 139, 0.35);
  border-color: var(--accent);
}

.inline-input {
  display: grid;
  gap: 0.5rem;
  grid-template-columns: 1fr auto;
  margin-bottom: 0.8rem;
}

.btn {
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.56rem 0.95rem;
  font-size: 0.75rem;
  cursor: pointer;
  transition: transform 120ms ease, background-color 120ms ease, border-color 120ms ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

.btn-accent {
  background: var(--accent);
  color: #fff;
}

.btn-accent:hover {
  background: var(--accent-strong);
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  border-color: var(--line);
}

.card-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.8rem;
}

.template-list {
  display: grid;
  gap: 0.5rem;
}

.template-item {
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--surface-strong);
  border-radius: 12px;
  padding: 0.55rem 0.65rem;
  cursor: pointer;
}

.template-item:hover {
  border-color: rgba(13, 143, 139, 0.6);
}

.template-item.active {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.template-item strong {
  display: block;
  font-size: 0.78rem;
}

.template-item span {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.72rem;
  color: var(--ink-soft);
}

.studio-header {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  flex-wrap: wrap;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.65);
  padding: 0.8rem 1rem;
}

.studio-header p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.73rem;
}

.link {
  margin-left: auto;
  color: var(--accent-strong);
  font-size: 0.73rem;
}

.table-wrap {
  overflow-x: auto;
  margin: 0.5rem 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 900px;
}

th,
td {
  font-size: 0.72rem;
  text-align: left;
  padding: 0.38rem;
  border-bottom: 1px dashed var(--line);
  vertical-align: top;
}

th {
  color: var(--ink-soft);
}

td input,
td select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.44rem 0.45rem;
  background: #fff;
  font-size: 0.7rem;
}

td button {
  width: 100%;
}

.actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.designer-host {
  min-height: 420px;
  border: 1px dashed var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.56);
  overflow: hidden;
  padding: 0.8rem;
}

.designer-host > p {
  margin: 0;
}

.split {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
}

.result {
  margin: 0.7rem 0 0;
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.7);
  min-height: 90px;
  padding: 0.65rem;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.72rem;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-top: 1.4rem;
  font-size: 0.78rem;
}

.checkbox input {
  width: auto;
  margin: 0;
}

.chip {
  display: inline-flex;
  gap: 0.4rem;
  align-items: center;
  font-size: 0.72rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  padding: 0.3rem 0.55rem;
  background: #fff;
}

@media (max-width: 1080px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .link {
    margin-left: 0;
  }
}
