:root {
  --bg: #eef1eb;
  --panel: #fcfcf8;
  --panel-2: #f5f7f1;
  --line: #ccd5c5;
  --text: #14201b;
  --muted: #5d6d64;
  --accent: #0f766e;
  --accent-2: #154e75;
  --danger: #b42318;
  --warn: #b54708;
  --shadow: 0 12px 30px rgba(20, 32, 27, 0.08);
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(15, 118, 110, 0.09), transparent 28%),
    radial-gradient(circle at top right, rgba(21, 78, 117, 0.08), transparent 26%),
    var(--bg);
}

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

button {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
  color: var(--text);
  padding: 0.6rem 0.9rem;
  cursor: pointer;
}

button:hover {
  border-color: var(--accent);
}

button.tool.active,
button.primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

label {
  display: grid;
  gap: 0.35rem;
  margin-bottom: 0.8rem;
}

label span {
  color: var(--muted);
  font-size: 0.9rem;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
  color: var(--text);
  padding: 0.65rem 0.8rem;
}

pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.hidden {
  display: none !important;
}

.panel.centered {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem;
}

.card {
  border: 1px solid rgba(204, 213, 197, 0.8);
  border-radius: 18px;
  background: rgba(252, 252, 248, 0.95);
  box-shadow: var(--shadow);
}

.login-card {
  width: min(420px, 92vw);
  padding: 2rem;
}

.subtle {
  color: var(--muted);
}

.error {
  color: var(--danger);
}

.warning {
  color: var(--warn);
  font-weight: 600;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  padding: 1rem 1.4rem;
  border-bottom: 1px solid var(--line);
  background: rgba(252, 252, 248, 0.88);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar h1 {
  margin: 0;
  font-size: 1.35rem;
}

.topbar-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 320px;
  gap: 1rem;
  padding: 1rem;
  min-height: calc(100vh - 85px);
}

.sidebar {
  background: rgba(252, 252, 248, 0.9);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 1rem;
  min-height: 0;
  overflow: auto;
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.8rem;
}

.sidebar-header h2,
.editor-card h3,
.status-card h3 {
  margin: 0;
  font-size: 1rem;
}

.sequence-list,
.instance-list {
  display: grid;
  gap: 0.7rem;
}

.sequence-item,
.instance-item {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel-2);
  padding: 0.8rem;
  cursor: pointer;
}

.sequence-item.active,
.instance-item.active {
  border-color: var(--accent);
  background: rgba(15, 118, 110, 0.08);
}

.sequence-item h3,
.instance-item h3 {
  margin: 0 0 0.4rem 0;
  font-size: 0.98rem;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.badge {
  padding: 0.18rem 0.45rem;
  border-radius: 999px;
  background: white;
  border: 1px solid var(--line);
  font-size: 0.75rem;
}

.viewer-column {
  display: grid;
  gap: 0.9rem;
  min-width: 0;
}

.viewer-toolbar,
.tool-row {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(252, 252, 248, 0.92);
  box-shadow: var(--shadow);
  padding: 0.85rem 1rem;
}

.toolbar-group {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.compact {
  margin: 0;
  display: flex;
  gap: 0.4rem;
  align-items: center;
}

.compact input {
  width: 6rem;
}

.stage-section {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(20, 32, 27, 0.04);
  box-shadow: var(--shadow);
  padding: 0.9rem;
  min-height: 520px;
}

.empty-state {
  min-height: 500px;
  display: grid;
  place-items: center;
  color: var(--muted);
  border: 2px dashed var(--line);
  border-radius: 14px;
}

.stage-container {
  position: relative;
  width: 100%;
  height: calc(100vh - 330px);
  min-height: 520px;
  overflow: auto;
  background: #101a15;
  border-radius: 14px;
}

.stage-container img,
.stage-container svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.stage-container img {
  object-fit: contain;
  background: #101a15;
}

.stage-container svg {
  pointer-events: all;
}

.status-strip {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.9rem;
}

.status-card,
.editor-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(252, 252, 248, 0.92);
  box-shadow: var(--shadow);
  padding: 1rem;
}

.editor-card {
  margin-top: 1rem;
}

#projectStatus {
  max-height: 220px;
  overflow: auto;
  font-size: 0.84rem;
  color: var(--muted);
}

@media (max-width: 1360px) {
  .layout {
    grid-template-columns: 270px minmax(0, 1fr);
  }

  .sidebar.right {
    grid-column: 1 / -1;
  }
}

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

  .status-strip {
    grid-template-columns: 1fr;
  }
}
