:root {
  font-family: 'Poppins', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: #111321;
  background-color: #f4f6fb;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: radial-gradient(circle at top, #f7fbff, #f0f4fb);
  min-height: 100vh;
  color: #141726;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 2rem;
  padding: 2.5rem clamp(1rem, 4vw, 4rem);
}

.app-header h1 {
  margin: 0.4rem 0 0.6rem;
  font-size: clamp(1.8rem, 3vw, 2.5rem);
}

.app-header p {
  margin: 0;
  line-height: 1.6;
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

button {
  border: none;
  border-radius: 999px;
  padding: 0.65rem 1.3rem;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  background: #e6e9f5;
  color: #111321;
  transition: transform 0.2s, box-shadow 0.2s;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(17, 19, 33, 0.1);
}

button.primary {
  background: #0c6cf8;
  color: #fff;
}

button.primary.ghost {
  border: 1px solid rgba(12, 108, 248, 0.3);
  background: transparent;
  color: #0c6cf8;
}

button.ghost {
  border: 1px solid rgba(17, 19, 33, 0.15);
  background: transparent;
}

button.ghost.danger {
  color: #d7263d;
  border-color: rgba(215, 38, 61, 0.5);
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 0.75rem;
  font-weight: 600;
  color: #5c627c;
}

.layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 320px;
  gap: 1.5rem;
  padding: 0 1.5rem 2rem;
}

.panel,
.canvas-panel {
  background: #fff;
  border-radius: 24px;
  padding: 1.5rem;
  box-shadow: 0 20px 80px rgba(18, 34, 83, 0.08);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.panel h2,
.panel h3 {
  margin: 0 0 0.75rem;
}

.panel-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.panel-section.split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

input,
select,
textarea {
  border: 1px solid rgba(17, 19, 33, 0.12);
  border-radius: 14px;
  padding: 0.6rem 0.9rem;
  font-family: inherit;
  font-size: 0.95rem;
  background: #f9fafc;
}

textarea {
  resize: vertical;
}

.plan-type-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.plan-type-card {
  border-radius: 16px;
  padding: 0.9rem 1rem;
  text-align: left;
  background: linear-gradient(120deg, rgba(203, 48, 52, 0.18), rgba(203, 48, 52, 0.05));
  color: #a41019;
}

.plan-type-card[data-plan='evacuation'] {
  background: linear-gradient(120deg, rgba(17, 164, 91, 0.18), rgba(17, 164, 91, 0.05));
  color: #138754;
}

.plan-type-card.active {
  border: 2px solid currentColor;
  background: #fff;
}

.tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tools button {
  border-radius: 12px;
}

.tips {
  font-size: 0.85rem;
  color: #5d6074;
  background: #f4f6fb;
  padding: 0.8rem 1rem;
  border-radius: 16px;
}

.panel-note {
  margin: 0;
  font-size: 0.85rem;
  color: #5d6074;
  background: #f4f6fb;
  padding: 0.5rem 0.85rem;
  border-radius: 14px;
}

.panel-note.success {
  color: #0f8b43;
  background: #e8f8ef;
}

.panel-note.error {
  color: #b42318;
  background: #fdecea;
}

.canvas-panel {
  padding: 0;
}

.plan-stage {
  position: relative;
  background: #f8fafc;
  border-radius: 24px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  overflow: auto;
}

.plan-title-ribbon {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  border-radius: 18px;
  background: linear-gradient(100deg, #b3111c, #dc3545);
  color: #fff;
}

.plan-title-ribbon[data-plan='evacuation'] {
  background: linear-gradient(100deg, #0f8b43, #00b368);
}

.plan-title-ribbon h3 {
  margin: 0.2rem 0 0;
}

.plan-title-ribbon p {
  margin: 0;
}

#plan-canvas {
  display: block;
  width: auto;
  height: auto;
  border-radius: 12px;
  background: #fff;
  box-shadow: inset 0 0 0 1px rgba(17, 19, 33, 0.08);
}

.legend {
  border-radius: 18px;
  padding: 1.25rem;
  background: #fff;
  box-shadow: inset 0 0 0 1px rgba(17, 19, 33, 0.08);
}

.legend-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.legend ul {
  list-style: none;
  padding: 0;
  margin: 1rem 0 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.legend-item span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.3rem;
  height: 2.3rem;
  border-radius: 12px;
  background: #f4f6fb;
  font-weight: 600;
}

.library-panel {
  gap: 1rem;
}

.icon-library {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 45vh;
  overflow-y: auto;
  padding-right: 0.5rem;
}

.icon-card {
  display: flex;
  gap: 1rem;
  align-items: center;
  padding: 0.85rem;
  border: 1px solid rgba(17, 19, 33, 0.1);
  border-radius: 16px;
}

.icon-card .icon-visual {
  width: 64px;
  height: 64px;
  border-radius: 20px;
  border: none;
  padding: 0;
  overflow: hidden;
  background: #f2f5fb;
}

.icon-label {
  font-weight: 600;
  margin: 0 0 0.4rem;
}

.icon-actions {
  display: flex;
  gap: 0.5rem;
}

.saved-plans {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.saved-plan {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.55rem 0.85rem;
  border-radius: 12px;
  background: #f4f6fb;
}

.saved-plan-details {
  display: flex;
  flex-direction: column;
}

.saved-plan time {
  font-size: 0.8rem;
  color: #5c627c;
}

.saved-plan span {
  font-weight: 500;
}

.saved-plan .actions {
  display: flex;
  gap: 0.3rem;
}

.saved-actions {
  display: flex;
  justify-content: flex-end;
}

.saved-actions button {
  border-radius: 10px;
}

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

  .library-panel {
    grid-column: span 2;
  }
}

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

  .library-panel {
    grid-column: span 1;
  }

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

  .header-actions {
    width: 100%;
  }
}
