:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --panel-dark: #111827;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --accent: #111827;
  --radius: 8px;
  --font: Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  -webkit-text-size-adjust: 100%;
}

.layout {
  display: flex;
  min-height: 100vh;
  height: 100vh;
  height: 100dvh;
}

.sidebar {
  width: 220px;
  background: var(--panel-dark);
  color: #fff;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: transform 0.2s ease, width 0.2s ease;
}

.brand {
  font-weight: 700;
  margin-bottom: 16px;
  position: relative;
}

.brand-title {
  font-size: 16px;
}

.brand-subtitle {
  font-size: 12px;
  color: #cbd5e1;
  margin-top: 4px;
}

.app-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.app-button {
  background: transparent;
  border: none;
  color: #cbd5e1;
  padding: 6px 0;
  text-align: left;
  cursor: pointer;
  font-size: 13px;
}

.app-button:hover {
  color: #fff;
}

.app-button.active {
  color: #fff;
  font-weight: 600;
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.main-header {
  padding: 24px 24px 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.main-title {
  font-size: 20px;
  margin-bottom: 8px;
}

.sidebar-toggle {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sidebar-toggle-desktop {
  position: absolute;
  top: 0;
  right: 0;
}

.sidebar-toggle-mobile {
  display: none;
  background: #e5e7eb;
  color: #111827;
}

.sidebar-toggle-desktop-main {
  display: none;
  background: #e5e7eb;
  color: #111827;
}

.main-content {
  flex: 1;
  padding: 24px;
  overflow: auto;
  display: flex;
  min-height: 0;
}

.main-toolbar {
  padding: 0 24px 24px 24px;
  position: sticky;
  bottom: 0;
  background: var(--bg);
  border-top: 1px solid var(--border);
  z-index: 2;
}

.clarify-banner {
  background: linear-gradient(135deg, #111827, #1f2937);
  color: #fff;
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.clarify-text {
  font-size: 13px;
  margin-right: 12px;
}

.clarify-close {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border: none;
  font-size: 16px;
  cursor: pointer;
  line-height: 1;
  border-radius: 999px;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.toolbar-card {
  background: var(--panel);
  padding: 12px;
  border-radius: var(--radius);
}

.toolbar-label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.toolbar-input {
  width: 100%;
  min-height: 90px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px;
  font-family: var(--font);
  font-size: 16px;
}

.preview-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.preview-img {
  width: 56px;
  height: 56px;
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid var(--border);
}

.toolbar-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.toolbar-status {
  margin-left: auto;
  text-align: right;
}

.app-frame {
  width: 100%;
  height: auto;
  flex: 1;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
}

.button {
  background: #e5e7eb;
  color: #111827;
  border: none;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-family: var(--font);
  font-size: 16px;
}

.button.primary {
  background: #111827;
  color: #fff;
}

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

.hidden {
  display: none;
}

.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid #cbd5e1;
  border-top-color: #111827;
  border-radius: 50%;
  display: inline-block;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 960px) {
  .layout {
    flex-direction: column;
  }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    height: 100dvh;
    width: 240px;
    transform: translateX(-100%);
    z-index: 5;
    box-shadow: 6px 0 18px rgba(15, 23, 42, 0.15);
  }
  .app-list {
    gap: 12px;
  }
  .toolbar-status {
    margin-left: 0;
    width: 100%;
  }
  .sidebar-toggle-desktop {
    display: none;
  }
  .sidebar-toggle-desktop-main {
    display: none;
  }
  .sidebar-toggle-mobile {
    display: inline-flex;
    margin-bottom: 8px;
  }
  .main-header {
    padding: 16px;
  }
  .main-title {
    margin-bottom: 0;
    flex: 1;
    text-align: center;
  }
}

.layout.sidebar-collapsed .sidebar {
  transform: translateX(-100%);
  width: 0;
  padding: 0;
  overflow: hidden;
}

.layout.sidebar-collapsed .sidebar-toggle-desktop-main {
  display: inline-flex;
}

.layout.sidebar-collapsed .main-title {
  margin-left: 0;
}

.layout.sidebar-open .sidebar {
  transform: translateX(0);
}
