/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
  background: #f1f5f9;
  color: #1e293b;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ===== UTILITIES ===== */
.hidden { display: none !important; }

/* ===== HEADER ===== */
header {
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  position: sticky;
  top: 0;
  z-index: 50;
}
.header-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.header-left { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.header-right { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.logo { display: inline-flex; align-items: center; }
.logo img { display: block; height: 64px; width: auto; }
#project-title-header { color: #64748b; font-size: 0.875rem; }

/* ===== BETA BANNER ===== */
.beta-banner {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border-bottom: 2px solid #f59e0b;
  padding: 0.75rem 1rem;
  text-align: center;
  font-size: 0.9rem;
  color: #92400e;
  line-height: 1.5;
  font-weight: 500;
}
.beta-banner strong { color: #b45309; font-weight: 700; }
.beta-disclaimer {
  background: #fee2e2;
  border-left: 4px solid #dc2626;
  padding: 1rem;
  margin: 1rem 0;
  border-radius: 0.4rem;
  font-size: 0.85rem;
  color: #7f1d1d;
  line-height: 1.6;
}
.beta-disclaimer strong { color: #991b1b; font-weight: 700; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.25rem;
  padding: 0.6rem 1.2rem; border-radius: 0.5rem; font-weight: 600; font-size: 0.9rem;
  cursor: pointer; border: none; transition: all 0.15s; min-height: 44px;
  white-space: nowrap; font-family: inherit;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: #1e40af; color: #fff; }
.btn-primary:hover { background: #1d4ed8; }
.btn-secondary { background: #f1f5f9; color: #334155; border: 1px solid #cbd5e1; }
.btn-secondary:hover { background: #e2e8f0; }
.btn-danger { background: #dc2626; color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.82rem; min-height: 34px; }

/* ===== TOGGLE GROUP ===== */
.toggle-group {
  .logo { display: inline-flex; align-items: center; font-size: 1.8rem; line-height: 1; }
}
.toggle-group button {
  padding: 0.35rem 0.85rem; font-size: 0.85rem; font-weight: 600; background: #f8fafc;
  color: #64748b; border: none; cursor: pointer; min-height: 36px; transition: all 0.15s;
}
.toggle-group button.active { background: #1e40af; color: #fff; }

/* ===== STATUS ===== */
.status-bar {
  font-size: 0.78rem; padding: 0.2rem 0.65rem; border-radius: 9999px; font-weight: 700;
}
.status-saved { background: #dcfce7; color: #16a34a; }
.status-saving { background: #fef9c3; color: #a16207; }
.status-error { background: #fee2e2; color: #dc2626; }

/* ===== SCREEN ===== */
.screen { display: none; }
.screen.active { display: block; }
.screen-content { max-width: 960px; margin: 0 auto; padding: 1.5rem 1rem 3rem; }
.screen-content.wall-editor-screen { max-width: none; padding: 1.5rem; }
.screen-content-narrow { max-width: 700px; margin: 0 auto; padding: 1.5rem 1rem 3rem; }
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.25rem; gap: 1rem; flex-wrap: wrap;
}
.section-header h1 { font-size: 1.75rem; font-weight: 800; color: #1e293b; }
.section-header h2 { font-size: 1.2rem; font-weight: 700; color: #1e293b; }
.section-subtitle { color: #64748b; font-size: 0.9rem; margin-top: 0.2rem; }

/* ===== CARDS ===== */
.card {
  background: #fff; border-radius: 0.75rem; padding: 1.25rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.07); border: 1px solid #e2e8f0;
}

/* ===== PROJECTS GRID ===== */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}
.project-card {
  background: #fff; border-radius: 0.75rem; padding: 1.25rem;
  border: 1px solid #e2e8f0; cursor: pointer; transition: all 0.15s; position: relative;
}
.project-card:hover { border-color: #93c5fd; box-shadow: 0 4px 16px rgba(30,64,175,0.1); }
.project-card h3 { font-size: 1.05rem; font-weight: 700; color: #1e293b; margin-bottom: 0.3rem; word-break: break-word; }
.project-meta { color: #64748b; font-size: 0.83rem; margin-top: 0.25rem; }
.tags { display: flex; gap: 0.4rem; margin-top: 0.75rem; flex-wrap: wrap; }
.tag { font-size: 0.73rem; font-weight: 600; padding: 0.15rem 0.55rem; border-radius: 9999px; }
.tag-blue { background: #eff6ff; color: #1d4ed8; }
.tag-gray { background: #f1f5f9; color: #475569; }
.project-delete-btn {
  position: absolute; top: 0.75rem; right: 0.75rem;
  opacity: 0; transition: opacity 0.15s;
}
.project-card:hover .project-delete-btn { opacity: 1; }

/* ===== EMPTY STATE ===== */
.empty-state { text-align: center; padding: 4rem 1rem; color: #94a3b8; }
.empty-icon { font-size: 3rem; margin-bottom: 0.75rem; }
.empty-title { font-size: 1.05rem; font-weight: 600; color: #64748b; }
.empty-hint { font-size: 0.875rem; margin-top: 0.3rem; color: #94a3b8; }

/* ===== SUMMARY ===== */
.summary-card { margin-bottom: 1.5rem; }
.summary-title { font-size: 0.875rem; font-weight: 700; color: #475569; margin-bottom: 1rem; text-transform: uppercase; letter-spacing: 0.04em; }
.summary-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; text-align: center; }
@media (max-width: 480px) { .summary-grid { grid-template-columns: repeat(2, 1fr); } }
.summary-value { font-size: 1.6rem; font-weight: 800; color: #1e40af; }
.summary-label { font-size: 0.72rem; color: #64748b; margin-top: 0.25rem; }

/* ===== WALLS LIST ===== */
.walls-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 0.75rem; }
.wall-card {
  background: #fff; border-radius: 0.6rem; padding: 1rem;
  border: 1px solid #e2e8f0; display: flex; align-items: flex-start;
  justify-content: space-between; gap: 0.75rem; transition: all 0.15s;
}
.wall-card:hover { border-color: #93c5fd; }
.wall-card-body { flex: 1; min-width: 0; }
.wall-card h4 { font-weight: 700; color: #1e293b; margin-bottom: 0.3rem; word-break: break-word; }
.wall-meta { font-size: 0.82rem; color: #64748b; line-height: 1.7; }
.wall-openings-hint { font-size: 0.78rem; color: #1d4ed8; margin-top: 0.25rem; }

/* ===== FORM ===== */
.form-group { margin-bottom: 0.7rem; }
.form-label { display: block; font-size: 0.77rem; font-weight: 600; color: #475569; margin-bottom: 0.2rem; }
.form-input {
  width: 100%; padding: 0.45rem 0.65rem; border: 1px solid #cbd5e1; border-radius: 0.4rem;
  font-size: 0.85rem; background: #fff; transition: border-color 0.15s; min-height: 36px;
  font-family: inherit; color: #1e293b;
}
.form-input:focus { outline: none; border-color: #1e40af; box-shadow: 0 0 0 3px rgba(30,64,175,0.12); }

/* ===== WALL FORM GRID ===== */
.wall-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; }
@media (max-width: 580px) { .wall-form-grid { grid-template-columns: 1fr; } }
.wall-form-grid .full-width { grid-column: 1 / -1; }

/* ===== WALL EDITOR LAYOUT ===== */
.wall-editor-container {
  display: grid;
  grid-template-columns: minmax(350px, 450px) 1fr;
  gap: 2rem;
  max-width: none;
  align-items: stretch;
  height: calc(100vh - 80px - 3rem);
}
@media (max-width: 1200px) { .wall-editor-container { grid-template-columns: 1fr; gap: 1.5rem; height: auto; align-items: start; } }
.wall-editor-form { min-width: 0; max-height: 100%; overflow-y: auto; padding-right: 0.5rem; }
.wall-editor-preview { min-width: 0; display: flex; flex-direction: column; }
.wall-editor-preview .card { display: flex; flex-direction: column; height: 100%; max-height: none; position: static; }
.wall-preview-wrap { flex: 1; display: flex; flex-direction: column; min-height: 0; border: 1px solid #dbe4f0; border-radius: 0.6rem; background: #f8fafc; padding: 0.75rem; position: relative; overflow: auto; }
#wall-preview-svg { flex: 1; width: 100%; height: 100%; display: block; background: transparent; border-radius: 0.4rem; border: 1px solid #e2e8f0; cursor: grab; user-select: none; transition: transform 0.1s ease-out; }
#wall-preview-svg:active { cursor: grabbing; }
.preview-legend { overflow-y: auto; flex-shrink: 0; padding-top: 1rem; border-top: 1px solid #ddd; }
@media (max-width: 1200px) {
  .wall-editor-form { max-height: none; overflow-y: visible; }
  .wall-editor-preview .card { position: static; max-height: none; }
  .wall-preview-wrap { height: auto; aspect-ratio: 1000 / 520; min-height: auto; }
  #wall-preview-svg { aspect-ratio: 1000 / 520; }
}

/* ===== OPENINGS ===== */
.opening-row {
  background: #f8fafc; border-radius: 0.5rem; padding: 0.875rem;
  border: 1px solid #e2e8f0; margin-bottom: 0.75rem;
}
.opening-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.75rem; margin-bottom: 0.6rem; }
@media (max-width: 540px) { .opening-grid { grid-template-columns: 1fr 1fr; } }

/* ===== COMPACT INPUT VIEW ===== */
.input-compact-preview {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid #e2e8f0;
}
.input-compact-preview h4 {
  font-size: 0.85rem;
  font-weight: 700;
  color: #334155;
  margin-bottom: 0.5rem;
}
.compact-table {
  width: 100%;
  font-size: 0.75rem;
  border-collapse: collapse;
  margin-bottom: 0.75rem;
  table-layout: fixed;
}
.compact-table th {
  text-align: left;
  padding: 0.35rem 0.5rem;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  font-weight: 600;
  color: #64748b;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.compact-table th:first-child,
.compact-table td:first-child {
  width: 2rem;
  text-align: center;
}
.compact-table td {
  padding: 0.35rem 0.5rem;
  border-bottom: 1px solid #f1f5f9;
  color: #334155;
  white-space: nowrap;
}
.compact-table .opening-selected-row {
  background: #eff6ff;
}
.compact-table .opening-selected-row td {
  border-bottom-color: #bfdbfe;
}
.compact-empty {
  text-align: center;
  color: #94a3b8;
}
@media (max-width: 768px) {
  .wall-editor-form { padding-right: 0; }
  .card { padding: 0.7rem; }
  .section-header { margin-bottom: 0.45rem; }
  .opening-row {
    padding: 0.55rem;
    margin-bottom: 0.4rem;
  }
  .opening-grid {
    gap: 0.45rem;
    margin-bottom: 0.4rem;
  }
  .compact-mobile-cards thead { display: none; }
  .compact-mobile-cards,
  .compact-mobile-cards tbody,
  .compact-mobile-cards tr,
  .compact-mobile-cards td {
    display: block;
    width: 100%;
  }
  .compact-mobile-cards tr {
    border: 1px solid #e2e8f0;
    border-radius: 0.35rem;
    background: #fff;
    padding: 0.18rem 0.3rem;
    margin-bottom: 0.2rem;
  }
  .compact-mobile-cards td {
    border: 0;
    padding: 0.05rem 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.35rem;
    font-size: 0.65rem;
    line-height: 1.2;
  }
  .compact-mobile-cards td::before {
    content: attr(data-label);
    color: #64748b;
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
  }
  .compact-mobile-cards .td-actions {
    display: none;
  }
  .compact-mobile-cards .compact-empty {
    display: block;
    text-align: center;
  }
}

/* ===== WALL PREVIEW ===== */
.preview-header { display: flex; align-items: center; gap: 0.75rem; margin: 0 0 0.75rem 0; flex-wrap: wrap; }
.preview-title { font-size: 1rem; font-weight: 700; color: #334155; flex: 1; min-width: 150px; }
.preview-controls { display: flex; gap: 0.5rem; }
.preview-btn { padding: 0.35rem 0.75rem; font-size: 0.82rem; background: #f1f5f9; border: 1px solid #cbd5e1; border-radius: 0.4rem; cursor: pointer; transition: all 0.15s; min-height: 34px; font-family: inherit; font-weight: 600; color: #334155; }
.preview-btn:hover { background: #e2e8f0; }
.preview-btn:active { transform: scale(0.97); }
@media (max-width: 1200px) {
  #wall-preview-svg { aspect-ratio: 1000 / 520; height: auto; }
}
#wall-preview-svg.fullscreen-active {
  position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; aspect-ratio: auto; border-radius: 0; z-index: 9999; background: transparent;
}
#preview-fullscreen-dialog {
  border: none; border-radius: 0.875rem; padding: 0; max-width: 100vw; width: 100vw; height: 100vh; max-height: 100vh;
}
#preview-fullscreen-dialog::backdrop { background: rgba(0,0,0,0.5); }
.preview-fullscreen-header {
  position: absolute; top: 1rem; right: 1rem; z-index: 10000; display: flex; gap: 0.5rem;
}
.preview-fullscreen-close {
  padding: 0.6rem 1.2rem; background: #fff; border: none; border-radius: 0.5rem; cursor: pointer; font-weight: 600; font-size: 0.9rem; box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.preview-fullscreen-close:hover { background: #f1f5f9; }
.preview-legend { margin-top: 0.75rem; font-size: 0.8rem; display: flex; flex-wrap: wrap; gap: 0.75rem; }
.legend-item { display: flex; align-items: center; gap: 0.35rem; }
.legend-color { width: 16px; height: 16px; border-radius: 2px; }

/* ===== SPECIFICATION ===== */
.preview-spec { margin-top: 1rem; padding-top: 0.75rem; border-top: 1px solid #e2e8f0; }
.preview-spec h4 { font-size: 0.85rem; font-weight: 700; color: #334155; margin-bottom: 0.5rem; }
.spec-table { width: 100%; font-size: 0.75rem; border-collapse: collapse; }
.spec-table th { text-align: left; padding: 0.35rem 0.5rem; background: #f8fafc; border-bottom: 1px solid #e2e8f0; font-weight: 600; color: #64748b; }
.spec-table td { padding: 0.35rem 0.5rem; border-bottom: 1px solid #f1f5f9; }
.spec-table tr:hover { background: #f8fafc; }


/* ===== FORM ACTIONS ===== */
.form-actions {
  display: flex; gap: 0.75rem; flex-wrap: wrap;
  margin-top: 2rem; padding-top: 1.5rem; border-top: 1px solid #e2e8f0;
}

/* ===== DIALOG ===== */
dialog {
  border: none; border-radius: 0.875rem; padding: 0;
  max-width: min(92vw, 440px); width: 100%; max-height: 92vh; overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}
dialog::backdrop { background: rgba(15,23,42,0.55); }
.dialog-body { padding: 1.75rem; }
.dialog-body h2 { font-size: 1.2rem; font-weight: 800; color: #1e293b; margin-bottom: 1.25rem; }
.dialog-actions { display: flex; gap: 0.75rem; margin-top: 1.5rem; }
.dialog-actions .btn { flex: 1; }

/* ===== TOAST ===== */
#toast-container {
  position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%);
  z-index: 9999; display: flex; flex-direction: column; align-items: center;
  gap: 0.5rem; pointer-events: none;
}
.toast {
  padding: 0.6rem 1.2rem; border-radius: 0.5rem; font-size: 0.875rem; font-weight: 500;
  box-shadow: 0 4px 14px rgba(0,0,0,0.18); animation: fadeIn 0.2s ease; white-space: nowrap;
}
.toast-success { background: #16a34a; color: #fff; }
.toast-error { background: #dc2626; color: #fff; }
.toast-info { background: #1e40af; color: #fff; }

/* ===== ANIMATIONS ===== */
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fadeIn 0.2s ease; }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: #f1f5f9; }
::-webkit-scrollbar-thumb { background: #94a3b8; border-radius: 3px; }

/* ===== SUBSCRIBE SECTION ===== */
.subscribe-section {
  margin-top: 2.5rem;
  padding: 2rem 1.5rem;
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
  border: 1px solid #bfdbfe;
  border-radius: 0.75rem;
  text-align: center;
}
.subscribe-icon { font-size: 2rem; margin-bottom: 0.5rem; }
.subscribe-section h3 {
  font-size: 1.15rem;
  font-weight: 700;
  color: #1e40af;
  margin-bottom: 0.4rem;
}
.subscribe-section > p {
  color: #475569;
  font-size: 0.9rem;
  margin-bottom: 1.25rem;
  line-height: 1.5;
}
.subscribe-form-row {
  display: flex;
  gap: 0.5rem;
  max-width: 420px;
  margin: 0 auto;
}
.subscribe-email-input { flex: 1; min-width: 0; }
.subscribe-success { color: #16a34a; font-weight: 600; font-size: 1rem; margin-top: 0.75rem; }
.subscribe-error { color: #dc2626; font-size: 0.875rem; margin-top: 0.75rem; }
@media (max-width: 480px) {
  .subscribe-form-row { flex-direction: column; }
}

/* ===== CHANGELOG DIALOG =====*/
