:root {
  color-scheme: light;
  font-family: "Segoe UI", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;
  --bg: #eef2f6;
  --bg-deep: #d8e0ea;
  --panel: #ffffff;
  --panel-muted: #f7f9fc;
  --panel-strong: #f2f6fb;
  --line: #d6dee8;
  --line-strong: #bac7d5;
  --text: #17202a;
  --muted: #667085;
  --muted-strong: #475467;
  --accent: #006eb8;
  --accent-dark: #00558f;
  --accent-soft: #e6f2fb;
  --success: #18865b;
  --success-soft: #e8f6ef;
  --danger: #b93815;
  --danger-dark: #922c11;
  --danger-soft: #fff0e8;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 12px 34px rgba(25, 39, 56, 0.12);
  --radius: 8px;
  --radius-sm: 6px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.64), rgba(238, 242, 246, 0.5) 28%),
    var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
}

button,
input,
select {
  font: inherit;
}

button {
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease, box-shadow 140ms ease, transform 80ms ease;
}

button:active:not(:disabled) {
  transform: translateY(1px);
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid rgba(0, 110, 184, 0.34);
  outline-offset: 2px;
}

.app-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: minmax(56px, auto) 44px 1fr 230px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), transparent),
    #111b25;
  color: #ffffff;
  border-bottom: 1px solid #0b121a;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.05) inset;
}

.topbar h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 650;
  letter-spacing: 0;
}

.status {
  display: block;
  margin-top: 2px;
  color: #b8c4d2;
  font-size: 12px;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.topbar-actions button,
.tab,
.tool-item {
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--text);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.topbar-actions button {
  padding: 7px 12px;
  color: #edf5ff;
  background: #172635;
  border-color: #30465a;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.topbar-actions button:hover {
  color: #ffffff;
  background: #20344a;
  border-color: #4d6880;
}

#openProjectBtn,
#saveProjectBtn {
  color: #ffffff;
  background: var(--accent);
  border-color: var(--accent-dark);
}

#openProjectBtn:hover,
#saveProjectBtn:hover {
  background: #087cc9;
  border-color: #0767a6;
}

.topbar-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

#startSimBtn {
  color: #eafff4;
  background: #123827;
  border-color: #226b4d;
}

#stopSimBtn {
  color: #fff4ed;
  background: #3c1d12;
  border-color: #8b3518;
}

.app-shell.simulation-mode #startSimBtn {
  color: #ffffff;
  background: var(--success);
}

.app-shell.simulation-mode #stopSimBtn:not(:disabled) {
  color: #ffffff;
  background: var(--danger);
}

.mode-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px 6px 14px;
  background: rgba(255, 255, 255, 0.84);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}

.mode-tab {
  min-width: 92px;
  padding: 7px 13px;
  color: var(--muted-strong);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.mode-tab:hover {
  color: var(--text);
  background: var(--panel-strong);
  border-color: var(--line);
}

.mode-tab.active {
  color: var(--accent-dark);
  background: var(--accent-soft);
  border-color: #bdddf3;
  box-shadow: inset 0 0 0 1px rgba(0, 110, 184, 0.08);
}

.app-view {
  display: none;
  min-height: 0;
}

.app-view.active {
  display: grid;
}

.workspace {
  min-height: 0;
  grid-template-columns: minmax(360px, 1fr) 320px;
  gap: 12px;
  padding: 12px;
}

.panel,
.preview-panel,
.bottom-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.panel {
  padding: 13px;
  overflow: auto;
}

.editor-sidebar {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.panel h2,
.preview-toolbar h2,
.bottom-header h2 {
  margin: 0;
  color: #111827;
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0;
}

.toolbox {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}

.sidebar-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 3px;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.sidebar-tab {
  min-width: 0;
  padding: 7px 8px;
  color: var(--muted-strong);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
}

.sidebar-tab:hover,
.sidebar-tab.is-drag-hover {
  color: var(--text);
  background: #ffffff;
  border-color: var(--line);
}

.sidebar-tab.active {
  color: var(--accent-dark);
  background: var(--accent-soft);
  border-color: #bdddf3;
}

.sidebar-tab-panel[hidden] {
  display: none;
}

.toolbox-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toolbox-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.toolbox-summary {
  color: var(--muted);
  font-size: 12px;
}

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

.toolbox-grid .tool-item[data-tool="screen"] {
  grid-column: 1 / -1;
}

.tool-item {
  width: 100%;
  padding: 9px 10px;
  text-align: left;
  touch-action: none;
  color: #213042;
  background: linear-gradient(180deg, #ffffff, #f8fafc);
  border-color: var(--line);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.tool-item:hover {
  color: var(--accent-dark);
  background: var(--accent-soft);
  border-color: #bdddf3;
}

.tool-item:active {
  cursor: grabbing;
}

.layer-panel {
  min-height: 0;
}

.layer-search {
  display: grid;
  gap: 5px;
  color: var(--muted-strong);
  font-size: 12px;
}

.layer-search input {
  width: 100%;
  padding: 7px 8px;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel-muted);
}

.layer-tree {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
  max-height: min(42vh, 460px);
  overflow: auto;
}

.layer-tree.drop-outdent {
  outline: 2px dashed var(--accent);
  outline-offset: -4px;
  background: rgba(0, 110, 184, 0.04);
}

.layer-empty {
  padding: 12px;
  color: var(--muted);
  font-size: 12px;
  background: var(--panel-muted);
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
}

.layer-node {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 8px 8px calc(8px + var(--layer-indent, 0px));
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, #ffffff, #f8fafc);
}

.layer-node.is-selected {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(0, 110, 184, 0.1);
  background: var(--accent-soft);
}

.layer-node.is-hidden-node {
  opacity: 0.58;
}

.layer-node.is-locked-node {
  background: linear-gradient(180deg, #f8fafc, #f1f5f9);
}

.layer-node.is-dragging {
  opacity: 0.42;
}

.layer-node.drop-before {
  box-shadow: inset 0 2px 0 var(--accent);
}

.layer-node.drop-after {
  box-shadow: inset 0 -2px 0 var(--accent);
}

.layer-node.drop-inside {
  border-color: var(--accent);
  background: #edf7ff;
}

.layer-node-main {
  width: 100%;
  min-width: 0;
  display: grid;
  grid-template-columns: 18px 22px minmax(0, 1fr) 26px 26px;
  align-items: center;
  gap: 5px;
  color: var(--text);
  font-weight: 600;
}

.layer-fold,
.layer-state-button {
  min-width: 0;
  height: 24px;
  padding: 0;
  color: var(--muted-strong);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.layer-fold:hover,
.layer-state-button:hover {
  color: var(--accent-dark);
  background: #ffffff;
  border-color: var(--line);
}

.layer-fold:disabled,
.layer-state-button:disabled {
  cursor: not-allowed;
  color: #98a2b3;
}

.layer-type-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  color: #1f2937;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 5px;
  font-size: 12px;
  line-height: 1;
}

.layer-name-label {
  width: 100%;
  min-width: 0;
  padding: 3px 5px;
  color: var(--text);
  overflow: hidden;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
  user-select: none;
}

.layer-node-main {
  cursor: grab;
  user-select: none;
}

.layer-node-main:active {
  cursor: grabbing;
}

.layer-children {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.preview-panel {
  min-width: 0;
  display: grid;
  grid-template-rows: 42px 1fr;
  overflow: hidden;
  border-color: var(--line-strong);
}

.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-muted);
}

.preview-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.preview-toolbar-actions label {
  display: flex;
  align-items: center;
  gap: 5px;
}

.preview-toolbar-actions select {
  min-width: 116px;
  padding: 4px 7px;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #ffffff;
}

.canvas-shell {
  position: relative;
  min-height: 0;
  width: 100%;
  aspect-ratio: 5 / 3;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.24) 1px, transparent 1px),
    linear-gradient(0deg, rgba(255, 255, 255, 0.24) 1px, transparent 1px),
    var(--bg-deep);
  background-size: 24px 24px;
  overflow: hidden;
}

#lvglCanvas,
.canvas-overlay {
  position: absolute;
}

#lvglCanvas {
  display: block;
  background: #eef3f8;
  border-radius: 2px;
  box-shadow: 0 0 0 1px #213042, 0 0 0 5px rgba(255, 255, 255, 0.46), 0 16px 34px rgba(15, 23, 42, 0.24);
}

.canvas-overlay {
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.app-shell.simulation-mode .canvas-shell {
  outline: 2px solid var(--success);
  outline-offset: -2px;
}

.app-shell.simulation-mode .canvas-overlay {
  display: none;
}

.app-shell.simulation-mode #lvglCanvas {
  touch-action: none;
  cursor: crosshair;
}

.control-item {
  position: absolute;
  pointer-events: auto;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  box-sizing: border-box;
  cursor: move;
  --control-color: #0077c8;
}

.control-screen {
  border: 2px solid #1f2d3d;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.04);
  cursor: default;
}

.control-screen .control-visual {
  align-items: flex-start;
  justify-content: flex-start;
  padding: 6px 8px;
  color: #334155;
  background: transparent;
  font-size: 12px;
}

.control-item.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(0, 110, 184, 0.24), 0 0 0 4px rgba(0, 110, 184, 0.12);
}

.control-item.is-locked {
  pointer-events: none;
  opacity: 0.72;
}

.control-visual {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: inherit;
  user-select: none;
  pointer-events: none;
}

.control-btn .control-visual {
  color: #ffffff;
  background: var(--control-color);
  border: 1px solid rgba(0, 0, 0, 0.14);
  font-size: 16px;
  line-height: 1;
  white-space: nowrap;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14);
}

.control-label .control-visual {
  justify-content: flex-start;
  color: var(--control-color);
  background: transparent;
  font-size: 16px;
  line-height: 1.2;
  white-space: nowrap;
}

.control-obj .control-visual {
  background: var(--control-color);
  border: 1px solid var(--line-strong);
}

.control-slider .control-visual {
  overflow: visible;
}

.slider-track,
.slider-fill {
  position: absolute;
  left: 0;
  top: calc(50% - 4px);
  height: 8px;
  border-radius: 4px;
}

.slider-track {
  width: 100%;
  background: #cbd5e1;
}

.slider-fill {
  background: var(--control-color);
}

.slider-knob {
  position: absolute;
  top: 50%;
  width: 20px;
  height: 20px;
  border: 1px solid #cbd5e1;
  border-radius: 50%;
  background: #ffffff;
  transform: translate(-50%, -50%);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.24);
}

.control-switch .control-visual {
  justify-content: flex-start;
  background: #cbd5e1;
  border-radius: 999px;
  padding: 2px;
}

.control-switch .control-visual.is-on {
  background: var(--control-color);
}

.switch-knob {
  width: calc(100% - 30px);
  min-width: 24px;
  max-width: 30px;
  height: calc(100% - 4px);
  min-height: 24px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.24);
  transform: translateX(0);
}

.control-switch .control-visual.is-on .switch-knob {
  transform: translateX(calc(100% + 2px));
}

.control-item .resize-handle {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: #ffffff;
  border: 1px solid var(--accent);
  opacity: 0;
}

.control-item.is-selected .resize-handle {
  opacity: 1;
}

.control-item .handle-br {
  right: -5px;
  bottom: -5px;
  cursor: se-resize;
}

.control-item .handle-tr {
  right: -5px;
  top: -5px;
  cursor: ne-resize;
}

.control-item .handle-bl {
  left: -5px;
  bottom: -5px;
  cursor: sw-resize;
}

.control-item .handle-tl {
  left: -5px;
  top: -5px;
  cursor: nw-resize;
}

.properties label {
  display: block;
  margin-bottom: 12px;
  color: var(--muted-strong);
  font-size: 12px;
}

.properties {
  padding-top: 13px;
  border-top: 1px solid var(--line);
}

.properties h2 {
  margin-bottom: 12px;
}

.properties label.is-hidden {
  display: none;
}

.properties input,
.properties select {
  width: 100%;
  margin-top: 5px;
  padding: 8px;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel-muted);
  box-shadow: inset 0 1px 1px rgba(15, 23, 42, 0.03);
}

.properties input:hover,
.properties select:hover,
.resource-card input:hover,
.resource-modal button:hover,
.resource-preview:hover {
  border-color: var(--line-strong);
}

.properties input[type="color"] {
  height: 38px;
  padding: 4px;
}

.properties input:disabled,
.properties select:disabled {
  color: #98a2b3;
  background: #eef1f5;
}

.properties .checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
}

.properties .checkbox-label input {
  width: auto;
  margin: 0;
}

.control-image .control-visual {
  color: #475467;
  background: linear-gradient(180deg, #eef2f6, #e3e9f0);
  border: 1px solid #98a2b3;
  font-size: 12px;
  text-align: center;
}

.control-image img {
  max-width: none;
  max-height: none;
  pointer-events: none;
  user-select: none;
}

.control-image .image-fit-original img {
  width: auto;
  height: auto;
}

.control-image .image-fit-fill img {
  width: 100%;
  height: 100%;
  object-fit: fill;
}

.control-image .image-fit-contain img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.control-image .image-fit-tile {
  background-repeat: repeat;
  background-position: left top;
}

.image-missing {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  color: #475467;
  background:
    linear-gradient(45deg, rgba(152, 162, 179, 0.25) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(152, 162, 179, 0.25) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(152, 162, 179, 0.25) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(152, 162, 179, 0.25) 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}

.danger-button,
.secondary-danger-button {
  width: 100%;
  margin-top: 4px;
  padding: 8px 10px;
  color: #ffffff;
  background: linear-gradient(180deg, #c54e2d, var(--danger));
  border: 1px solid var(--danger-dark);
  border-radius: var(--radius-sm);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), var(--shadow-sm);
  cursor: pointer;
}

.danger-button:hover {
  background: linear-gradient(180deg, #ca5d3b, #a83f1a);
}

.secondary-danger-button {
  color: var(--danger-dark);
  background: var(--danger-soft);
  border-color: #f1b99f;
  box-shadow: var(--shadow-sm);
}

.secondary-danger-button:hover {
  background: #ffe4d5;
}

.danger-button:disabled,
.secondary-danger-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.secondary-danger-button.is-hidden {
  display: none;
}

.panel-note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.bottom-panel {
  margin: 0 12px 12px;
  overflow: hidden;
  display: grid;
  grid-template-rows: 42px 1fr;
  border-color: var(--line-strong);
}

.logic-view {
  grid-template-rows: 42px 1fr;
  margin: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.logic-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #f9fbfd, #eef3f8);
}

.logic-header h2 {
  margin: 0;
  font-size: 15px;
}

#blocklyStatus {
  color: var(--muted);
  font-size: 12px;
}

.logic-content {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(360px, 1fr) 340px;
}

#blocklyWorkspace {
  min-height: 0;
  width: 100%;
  height: 100%;
}

.c-snippet-panel {
  min-width: 0;
  border-left: 1px solid var(--line);
  background: linear-gradient(180deg, #fcfdff, #f4f7fb);
  display: grid;
  grid-template-rows: 42px 1fr;
}

.c-snippet-panel h2 {
  margin: 0;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  font-size: 15px;
}

#cSnippetPreview {
  margin: 0;
  padding: 12px;
  overflow: auto;
  color: #1f2937;
  font-family: Consolas, Monaco, monospace;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.bottom-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #f9fbfd, #eef3f8);
}

#projectJson {
  margin: 0;
  padding: 12px;
  overflow: auto;
  color: #1f2937;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  z-index: 1000;
  max-width: min(520px, calc(100vw - 32px));
  padding: 10px 14px;
  color: #ffffff;
  background: rgba(16, 24, 32, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.28);
  font-size: 13px;
  line-height: 1.4;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 8px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.38);
}

.modal-backdrop[hidden] {
  display: none;
}

.resource-modal {
  width: min(760px, 100%);
  max-height: min(720px, calc(100vh - 48px));
  display: grid;
  grid-template-rows: 48px 1fr;
  overflow: hidden;
  background: linear-gradient(180deg, #ffffff, #f7f9fc);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}

.resource-modal-header,
.resource-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.resource-modal-header {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #f9fbfd, #eef3f8);
}

.resource-modal-header h2 {
  margin: 0;
  font-size: 15px;
}

.resource-modal button {
  padding: 7px 12px;
  color: var(--text);
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.resource-modal-body {
  min-height: 0;
  display: grid;
  grid-template-rows: 44px 1fr;
  gap: 10px;
  padding: 12px;
}

.resource-actions {
  color: var(--muted-strong);
  font-size: 12px;
}

.resource-list {
  min-height: 0;
  overflow: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}

.resource-empty {
  grid-column: 1 / -1;
  padding: 18px;
  color: var(--muted);
  background: var(--panel-muted);
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
}

.resource-card {
  display: grid;
  grid-template-rows: 128px auto auto;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #fcfdff, #f5f8fc);
  box-shadow: var(--shadow-sm);
}

.resource-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background:
    linear-gradient(45deg, #d8dee6 25%, transparent 25%),
    linear-gradient(-45deg, #d8dee6 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #d8dee6 75%),
    linear-gradient(-45deg, transparent 75%, #d8dee6 75%);
  background-color: #ffffff;
  background-size: 18px 18px;
  background-position: 0 0, 0 9px, 9px -9px, -9px 0;
  border: 1px solid #d1d9e3;
  border-radius: var(--radius-sm);
}

.resource-preview img {
  max-width: 100%;
  max-height: 100%;
}

.resource-meta {
  color: var(--muted);
  font-size: 12px;
}

.resource-card input {
  width: 100%;
  padding: 7px;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel-muted);
}

@media (max-width: 960px) {
  .app-shell {
    grid-template-rows: auto auto auto 230px;
  }

  .topbar,
  .workspace {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .workspace {
    display: block;
  }

  .workspace.app-view:not(.active) {
    display: none;
  }

  .logic-content {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(320px, 1fr) 220px;
  }

  .c-snippet-panel {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .panel,
  .preview-panel {
    margin-bottom: 12px;
  }
}

@media (max-width: 1280px) {
  .topbar-actions {
    max-width: 62vw;
    justify-content: flex-end;
  }

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

@media (max-width: 760px) {
  .topbar-actions {
    max-width: none;
  }

  .mode-tabs {
    overflow-x: auto;
  }

  .resource-list {
    grid-template-columns: 1fr;
  }
}
