:root {
  --bg-color: #f8fafc; /* Slate-50 - Very light cool gray */
  --text-primary: #334155; /* Slate-700 */
  --text-secondary: #64748b; /* Slate-500 */
  --card-bg: #ffffff;
  --header-bg: #ffffff;
  --shadow-soft: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
  --shadow-medium: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.025);
  --border-radius: 16px;
  --font-main: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --accent-color: #3b82f6; /* Soft blue */
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  font-family: var(--font-main);
  color: var(--text-primary);
  background: url('./materials/wood-bg.png') center / cover no-repeat fixed;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.app-header {
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.3);
  color: #fff;
  padding: clamp(0.75rem, 1.8vw, 1.2rem) clamp(1rem, 3vw, 2rem);
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 14px;
}

.header-logo {
  width: clamp(28px, 4vw, 36px);
  height: clamp(28px, 4vw, 36px);
  flex-shrink: 0;
}

.header-text {
  min-width: 0;
}

.header-text h1 {
  margin: 0;
  font-size: clamp(1rem, 2.4vw, 1.4rem);
  font-weight: 700;
  color: #fff;
  letter-spacing: 0;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.header-text p {
  margin: 2px 0 0;
  font-size: clamp(0.72rem, 1.8vw, 0.8rem);
  color: rgba(255, 255, 255, 0.6);
  font-weight: 400;
  line-height: 1.35;
}

.app-main {
  display: flex;
  justify-content: center;
  width: 100%;
  max-width: 1600px;
  margin: clamp(0.75rem, 2vw, 1.5rem) auto;
  padding: 0 clamp(0.75rem, 2.5vw, 1.5rem);
}

.visual-panel {
  background: var(--card-bg);
  border-radius: clamp(8px, 1.8vw, var(--border-radius));
  box-shadow: var(--shadow-medium);
  width: 100%;
  min-width: 0;
  overflow: hidden;
  border: 1px solid rgba(226, 232, 240, 0.6); /* Light border */
  transition: box-shadow 0.3s ease;
  display: flex; /* To center content if needed */
  justify-content: center;
}

.visual-panel:hover {
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.05), 0 10px 10px -5px rgba(0, 0, 0, 0.02);
}

#tree-container {
  width: 100%;
  height: min(850px, calc(100svh - 128px));
  min-height: 560px;
  cursor: grab;
  touch-action: none; /* Improve touch handling on iPad */
}

#tree-container:active {
  cursor: grabbing;
}

#tree-container svg {
  display: block;
  width: 100%;
  height: 100%;
}

/* Clean Footer */
.app-footer {
  text-align: center;
  padding: 2rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* Tree Styling adjustments for minimalist look */
.node circle {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.node rect {
  transition: fill 0.3s ease, stroke 0.3s ease, stroke-width 0.3s ease, filter 0.25s ease;
}

.node:hover rect {
  filter: drop-shadow(0 6px 14px rgba(0,0,0,0.22));
  stroke-width: 2;
}

.node text {
  font-family: var(--font-main);
  font-size: 15px;
  letter-spacing: 0;
  pointer-events: none; /* Let clicks pass to rect/group */
}

/* Video Modal */
.video-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: clamp(0.75rem, 3vw, 2rem);
}

.video-modal.is-open {
  display: flex;
}

.video-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.video-modal__dialog {
  position: relative;
  width: min(960px, 100%);
  background: #0f172a;
  border-radius: 14px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
  overflow: hidden;
  animation: video-modal-in 0.2s ease;
}

@keyframes video-modal-in {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.video-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  color: #f1f5f9;
}

.video-modal__title {
  font-size: 0.95rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.video-modal__close {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  color: #f1f5f9;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s ease;
}

.video-modal__close:hover {
  background: rgba(255, 255, 255, 0.22);
}

.video-modal__frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
}

.video-modal__frame iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* iPad / Tablet Responsiveness */
@media (max-width: 1024px) {
  .app-header {
    position: sticky;
  }

  .app-main {
    margin: 1rem auto;
    padding: 0 1rem;
  }

  #tree-container {
    height: calc(100svh - 112px);
    min-height: 520px;
  }
}

@media (max-width: 640px) {
  body {
    background-attachment: scroll;
  }

  .app-header {
    padding: 0.75rem 0.875rem;
  }

  .header-inner {
    gap: 10px;
  }

  .header-text h1 {
    max-width: 100%;
  }

  .app-main {
    margin: 0.75rem auto;
    padding: 0 0.625rem;
  }

  .visual-panel {
    border-radius: 8px;
  }

  #tree-container {
    height: calc(100svh - 104px);
    min-height: 460px;
  }
}
