/**
 * 마당설계소 — 전역 스타일
 */

:root {
  --bg-dark: #1e293b;
  --bg-panel: #f1f5f9;
  --bg-white: #ffffff;
  --border: #cbd5e1;
  --accent: #0d9488;
  --accent-hover: #0f766e;
  --danger: #dc2626;
  --text: #0f172a;
  --muted: #64748b;
  --toolbar-h: 56px;
  --status-h: 28px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, 'Segoe UI', Arial, sans-serif;
  color: var(--text);
}

.hidden {
  display: none !important;
}

/* ----- Home ----- */
.home-body {
  min-height: 100vh;
  background: linear-gradient(160deg, #ecfdf5 0%, #e0f2fe 100%);
  padding: 32px 20px 48px;
}

.home-header {
  max-width: 720px;
  margin: 0 auto 32px;
}

.home-header h1 {
  margin: 0 0 12px;
  font-size: 2rem;
  color: #0f766e;
}

.home-lead {
  margin: 0 0 24px;
  line-height: 1.6;
  color: var(--muted);
  font-size: 1.05rem;
}

.home-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.home-list-section {
  max-width: 800px;
  margin: 0 auto;
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 24px;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.06);
}

.home-list-section h2 {
  margin: 0 0 16px;
  font-size: 1.2rem;
}

.project-ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.project-li {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 12px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid #e2e8f0;
}

.project-li:last-child {
  border-bottom: none;
}

.project-meta {
  font-weight: 600;
}

.project-date {
  font-size: 0.8rem;
  color: var(--muted);
}

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

/* ----- Buttons ----- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-white);
  color: var(--text);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
}

.btn:hover {
  background: #f8fafc;
}

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

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

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--accent);
}

.btn-danger {
  border-color: #fecaca;
  background: #fef2f2;
  color: var(--danger);
}

.btn-danger:hover {
  background: #fee2e2;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}

.btn-icon {
  min-width: 40px;
  padding-left: 12px;
  padding-right: 12px;
}

/* ----- Editor layout ----- */
.editor-body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background: #e8edf2;
}

.toolbar {
  height: var(--toolbar-h);
  min-height: var(--toolbar-h);
  background: var(--bg-dark);
  color: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px 0 16px;
  gap: 12px;
  flex-wrap: wrap;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toolbar-label {
  font-size: 0.8rem;
  color: #94a3b8;
}

.toolbar-input {
  min-width: 180px;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid #475569;
  background: #334155;
  color: #fff;
}

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

.toolbar .btn {
  background: #334155;
  border-color: #475569;
  color: #f1f5f9;
  padding: 8px 12px;
  font-size: 0.8rem;
}

.toolbar .btn:hover {
  background: #475569;
}

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

.toolbar .btn-ghost {
  color: #94a3b8;
  border-color: transparent;
  background: transparent;
}

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

.palette {
  width: 220px;
  min-width: 200px;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 12px;
}

.palette-title {
  margin: 0 0 12px;
  font-size: 1rem;
  color: var(--text);
}

.palette-section {
  margin-bottom: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-white);
  padding: 4px 8px;
}

.palette-section summary {
  cursor: pointer;
  font-weight: 600;
  padding: 6px 4px;
}

.palette-buttons {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-bottom: 8px;
}

.palette-btn {
  text-align: left;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #f8fafc;
  cursor: pointer;
  font-size: 0.85rem;
}

.palette-btn-inner {
  display: flex;
  align-items: center;
  gap: 10px;
}

.palette-dot {
  flex-shrink: 0;
  display: block;
  border-radius: 4px;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.08);
}

.palette-label {
  flex: 1;
  line-height: 1.35;
}

.palette-btn:hover {
  background: #ecfdf5;
  border-color: var(--accent);
}

.canvas-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  min-width: 0;
  overflow: auto;
  background: #dce3ea;
}

#madang-canvas {
  display: block;
  max-width: 100%;
  height: auto;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
}

.properties {
  width: 280px;
  min-width: 260px;
  background: var(--bg-white);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  padding: 12px;
}

.properties-title {
  margin: 0 0 12px;
  font-size: 1rem;
}

.properties-object-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.property-dot {
  flex-shrink: 0;
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.1);
  background: #fff;
}

.properties-object-meta {
  flex: 1;
  min-width: 0;
}

.properties-type-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--accent);
  background: #ecfdf5;
  padding: 4px 10px;
  border-radius: 6px;
}

.properties-empty {
  color: var(--muted);
  font-size: 0.9rem;
}

.properties-fields .field {
  margin-bottom: 10px;
}

.properties-fields label {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 4px;
}

.properties-fields input[type='text'],
.properties-fields input[type='number'],
.properties-fields select,
.properties-fields textarea {
  width: 100%;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.85rem;
}

.properties-fields textarea {
  min-height: 64px;
  resize: vertical;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.field-inline {
  display: flex;
  gap: 16px;
  margin-bottom: 10px;
  font-size: 0.85rem;
}

.field-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.prop-sub {
  margin: 16px 0 8px;
  font-size: 0.85rem;
  color: var(--accent);
}

.statusbar {
  height: var(--status-h);
  min-height: var(--status-h);
  background: #334155;
  color: #cbd5e1;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 16px;
  font-size: 0.75rem;
}

.status-selection {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 40%;
  min-width: 0;
}

.status-dot-wrap {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
}

.status-dot {
  display: block;
  border-radius: 4px;
  vertical-align: middle;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.15);
}

.status-selection-prefix {
  color: #94a3b8;
}

.status-selection-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

/* ----- Mobile ----- */
@media (max-width: 900px) {
  .editor-main {
    flex-direction: column;
  }

  .palette {
    width: 100%;
    min-width: 0;
    max-height: 200px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .properties {
    width: 100%;
    min-width: 0;
    max-height: 240px;
    border-left: none;
    border-top: 1px solid var(--border);
  }

  .canvas-wrap {
    flex: 1;
    min-height: 240px;
  }

  .toolbar {
    height: auto;
    padding: 8px;
  }

  .project-li {
    grid-template-columns: 1fr;
    gap: 8px;
  }
}
