/* Layout Styles - Main structure and positioning */
.layout {
  width: 100%;
  min-height: 100vh;
  height: 100vh;
  max-height: 100vh;
  display: flex;
  position: relative;
  z-index: 1;
  flex: 1;
}

@supports (height: 100dvh) {
  .layout {
    min-height: 100dvh;
    height: 100dvh;
    max-height: 100dvh;
  }
}

.card {
  flex: 1;
  background: var(--card-overlay);
  border: none;
  border-radius: 0;
  padding: 0;
  position: relative;
  /* ensure card content sits above overlay */
  z-index: 1001;
  height: 100%;
  overflow-y: auto;
  scroll-padding-bottom: calc(96px + max(env(safe-area-inset-bottom, 0px), var(--mobile-bottom-offset, 0px)));
  animation: pop 600ms ease;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.card::-webkit-scrollbar {
  width: 6px;
}

.card::-webkit-scrollbar-track {
  background: transparent;
}

.card::-webkit-scrollbar-thumb {
  background: rgba(176, 181, 188, 0.12);
  border-radius: 3px;
}

.card::-webkit-scrollbar-thumb:hover {
  background: rgba(176, 181, 188, 0.2);
}

.chat-container {
  flex: 1 1 auto;
  overflow-y: visible;
  padding: 0 28px 28px 28px;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
}

.input-island {
  position: sticky;
  bottom: max(env(safe-area-inset-bottom, 0px), var(--mobile-bottom-offset, 0px));
  left: 0;
  right: 0;
  padding: 12px 28px calc(12px + max(env(safe-area-inset-bottom, 0px), var(--mobile-bottom-offset, 0px)));
  background: var(--card);
  border-top: 1px solid var(--stroke);
  z-index: 10;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
}

@keyframes pop {
  from {
    transform: scale(0.98);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.title {
  display: flex;
  gap: 12px;
  align-items: center;
  margin: 0 0 12px 0;
  transition: transform 420ms ease, opacity 300ms ease;
  text-shadow: none;
}

.badge {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid var(--stroke);
  padding: 6px 10px;
  border-radius: 0;
  background: transparent;
}

h1 {
  margin: 0;
  padding-top: 32px; /* push down */
  margin-bottom: 12px;
  font-size: 32px; /* larger heading */
  transition: transform 420ms ease;
  text-shadow: none;
}

:root[data-theme="light"] h1 {
  color: #111827;
}

:root[data-theme="light"] .title h1 {
  color: #111827;
  text-shadow: none;
}

:root[data-theme="light"] #mainTitle {
  color: #000000;
  background-image: none;
  -webkit-text-fill-color: #000000;
}

.mode-panel {
  width: 100%;
  height: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
}

#qaPanel,
#quizPanel,
#todoPanel {
  min-height: 100%;
}

#qaPanel > .input-island,
#quizPanel > .input-island,
#todoPanel .todo-pane > .input-island {
  margin-top: auto;
}

#todoPanel {
  flex-direction: row;
  align-items: stretch;
  height: 100%;
}

#todoPanel .todo-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

#todoPanel .todo-pane > .input-island {
  width: 100%;
  max-width: none;
  margin: 0;
}

#todoPanel .chat-container {
  flex: 1;
  padding: 28px;
}

.todo-planner {
  width: 280px;
  /* align with the main pane background rather than sidebar/card */
  background: var(--bg-1);
  border-left: 1px solid var(--stroke);
  display: flex;
  flex-direction: column;
  min-height: 100%;
  overflow-y: auto;
}

/* light theme keeps same bg-1 but explicitly set for clarity */
:root[data-theme="light"] .todo-planner {
  background: var(--bg-1) !important;
  border-left-color: var(--stroke);
}

.planner-header {
  padding: 18px;
  border-bottom: 1px solid var(--stroke);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.planner-header h2 {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.planner-btn {
  height: 30px;
  padding: 0 12px;
  border-radius: 0;
  border: 1px solid var(--stroke);
  background: transparent;
  color: var(--text);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  box-shadow: none;
}

.planner-btn:hover {
  filter: brightness(1.06);
}

.planner-content {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
  position: relative;
}

.planner-content::-webkit-scrollbar {
  width: 6px;
}

.planner-content::-webkit-scrollbar-track {
  background: transparent;
}

.planner-content::-webkit-scrollbar-thumb {
  background: rgba(176, 181, 188, 0.12);
  border-radius: 3px;
}

.planner-content::-webkit-scrollbar-thumb:hover {
  background: rgba(176, 181, 188, 0.2);
}

.planner-content.is-loading::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.08), transparent);
  transform: translateX(-100%);
  animation: plannerShimmer 1.1s infinite;
  pointer-events: none;
}

@keyframes plannerShimmer {
  to {
    transform: translateX(100%);
  }
}

.planner-content :is(h1, h2, h3, h4) {
  margin: 0 0 8px 0;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-shadow: none;
}

.planner-content h1 {
  font-size: 16px;
}

.planner-content h2 {
  font-size: 14px;
}

.planner-content h3,
.planner-content h4 {
  font-size: 13px;
}

.planner-content :is(p, ul, ol, blockquote, pre) {
  margin: 0 0 10px 0;
}

.planner-content :is(ul, ol) {
  padding-left: 18px;
}

.planner-content code {
  font-size: 12px;
}

.planner-empty {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 20px 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
}


.mode-panel.is-hidden {
  display: none;
  pointer-events: none;
}

.mode-panel.fade-in {
  animation: panelFadeIn 240ms ease-out;
}

@keyframes panelFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.card.is-empty .title {
  transform: none;
}

.card.is-empty .footnote {
  opacity: 0;
  transform: none;
}

.card.is-empty #todoPanel .title,
.card.is-empty #todoPanel .footnote {
  transform: none;
  opacity: 0;
}

.footnote {
  color: var(--muted);
  font-size: 13px;
  opacity: 0;
  margin-bottom: 12px;
  transition: opacity 300ms ease, transform 420ms ease;
}

/* Mobile styles */
@media (max-width: 768px) {
  .card {
    background: var(--card);
  }
  
  .layout {
    z-index: auto;
  }

  .input-island {
    bottom: max(env(safe-area-inset-bottom, 0px), var(--mobile-bottom-offset, 0px));
    padding: 10px 20px calc(10px + max(env(safe-area-inset-bottom, 0px), var(--mobile-bottom-offset, 0px)));
  }

  .chat-container {
    padding: 20px 20px 20px 20px;
  }

  .title {
    padding-left: 56px;
    min-height: 44px;
    align-items: center;
    margin: 0 0 16px 0;
  }

  h1 {
    padding-top: 0;
    font-size: 24px;
    line-height: 1.1;
  }

  #todoPanel {
    flex-direction: column;
  }

  #todoPanel .chat-container {
    padding: 20px 20px 16px 20px;
  }

  .todo-planner {
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--stroke);
    max-height: 45vh;
  }

  .planner-header {
    position: sticky;
    top: 0;
    background: var(--card);
    z-index: 2;
  }

  .planner-content {
    padding: 16px;
    font-size: 14px;
    line-height: 1.7;
  }
}
