:root {
  --ink: #1f2a2e;
  --muted: #4a5a60;
  --accent: #1f6f78;
  --accent-dark: #16545a;
  --paper: #f2efe9;
  --card: #fffdf8;
  --line: #d7d1c6;
  --shadow: 0 14px 40px rgba(19, 28, 32, 0.12);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  background: radial-gradient(circle at top left, #ffffff 0%, #f6f1e7 45%, #efe7d8 100%);
  color: var(--ink);
  min-height: 100vh;
}

.app-header,
.app-shell {
  max-width: 2560px;
  margin: 0 auto;
}

.app-header {
  border-radius: 0 0 24px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 32px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  gap: 16px;
  align-items: center;
}

.brand-mark {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: var(--accent);
  color: #ffffff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: 0.5px;
}

.app-header h1 {
  font-family: "Georgia", "Times New Roman", serif;
  font-size: 1.6rem;
}

.app-header p {
  color: var(--muted);
  margin-top: 4px;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 24px;
  padding: 28px 32px;
}

.side-nav {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 20px;
  box-shadow: var(--shadow);
  height: fit-content;
}

.side-nav h2 {
  font-size: 1.1rem;
  margin-bottom: 12px;
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nav-btn {
  text-align: left;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  color: var(--muted);
  font-weight: 600;
  transition: all 0.2s;
}

.nav-btn:hover {
  background: rgba(0,0,0,0.03);
}

.nav-btn.active {
  background: #e5f0f2;
  border-color: #c6dde0;
  color: var(--accent-dark);
}

.nav-btn--link {
  margin-top: 12px;
  border-top: 1px solid #dde;
  padding-top: 14px;
  color: var(--accent-dark);
  font-weight: 600;
  text-decoration: none;
  display: block;
}
.nav-btn--link:hover {
  background: #e5f0f2;
}

.content-area {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.content-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.page-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.page-count {
  font-weight: 700;
}

.page-hint {
  color: var(--muted);
  font-size: 0.9rem;
}

.content-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  align-items: start;
  position: relative;
}

.editor-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 32px;
  min-height: 480px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}

.editor-card h2 {
  font-family: "Georgia", "Times New Roman", serif;
  font-size: 1.8rem;
  margin-bottom: 24px;
  color: var(--ink);
}

#section-body {
  line-height: 1.7;
  display: flex;
  flex-direction: column;
  gap: 18px;
  font-size: 1.05rem;
}

#section-body h3 {
  margin-top: 12px;
  font-size: 1.3rem;
  color: var(--accent-dark);
}

#section-body ul, 
#section-body ol {
  padding-left: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#section-body li {
  margin-bottom: 4px;
}

#section-body pre {
  background: rgba(0,0,0,0.05);
  padding: 16px;
  border-radius: 8px;
  font-family: monospace;
  font-size: 0.9rem;
  overflow-x: auto;
  border: 1px solid rgba(0,0,0,0.05);
}

.open-prompt-inline {
  align-self: flex-start;
  margin: 12px 0;
}

/* --- Drag-and-drop Noter --- */
.note-card {
  background: #fff59d !important;
  border: 1px solid #fbc02d;
  border-radius: 2px;
  padding: 0;
  box-shadow: 3px 3px 12px rgba(0,0,0,0.15);
  display: flex;
  flex-direction: column;
  color: #5d4037;
  font-size: 0.9rem;
  position: fixed;
  width: 320px;
  right: 32px;
  top: 140px;
  z-index: 100;
  transition: box-shadow 0.2s;
}

.note-card.dragging {
  box-shadow: 8px 12px 24px rgba(0,0,0,0.2);
  opacity: 0.95;
}

.notes-handle {
  background: rgba(0,0,0,0.05);
  padding: 10px 12px;
  cursor: move;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid rgba(0,0,0,0.05);
}

.handle-icon {
  font-size: 1.2rem;
  color: #978a3c;
}

.handle-title {
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 1px;
}

.notes-tabs {
  display: flex;
  background: rgba(0,0,0,0.03);
  border-bottom: 1px solid rgba(0,0,0,0.05);
  overflow-x: auto;
}

.notes-tab {
  flex: 1;
  padding: 8px 4px;
  text-align: center;
  font-size: 0.7rem;
  font-weight: 700;
  cursor: pointer;
  border-right: 1px solid rgba(0,0,0,0.05);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: rgba(0,0,0,0.02);
}

.notes-tab.active {
  background: #fff59d;
  border-bottom: 2px solid #fbc02d;
}

.notes-content {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tab-name-editor {
  display: none;
  width: 100%;
  padding: 6px 10px;
  border: 1px solid #fbc02d;
  background: #fff;
  border-radius: 4px;
  font-size: 0.85rem;
  margin-bottom: 4px;
}

.tab-name-editor.visible {
  display: block;
}

.note-card textarea {
  width: 100%;
  border: none;
  background: transparent;
  font-family: "Comic Sans MS", cursive, sans-serif;
  color: #5d4037;
  min-height: 240px;
  resize: vertical;
  line-height: 1.5;
  outline: none;
}

.notes-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 12px 10px;
}

.notes-hint {
  font-size: 0.65rem;
  opacity: 0.6;
  font-style: italic;
  margin: 0;
}

.prompt-icon-btn {
  background: rgba(0,0,0,0.05);
  border: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.8rem;
}

/* --- Knapper --- */
.primary-btn {
  background: var(--accent);
  color: #ffffff;
  padding: 10px 20px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.2s;
}

.primary-btn:hover {
  background: var(--accent-dark);
}

.primary-btn:disabled {
  background: #a7c7cc;
  cursor: not-allowed;
}

/* --- Footer sektion --- */
.content-footer {
  margin-top: 32px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.note {
  background: rgba(255, 255, 255, 0.6);
  padding: 16px 20px;
  border-radius: 12px;
  border: 1px dashed var(--line);
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.5;
}

.note-alert {
  color: #c0392b;
  display: block;
  margin-top: 4px;
}

.nav-buttons-bottom {
  display: flex;
  gap: 12px;
  justify-content: flex-start;
}

.footer {
  text-align: center;
  padding: 24px 0 40px;
  color: #4b5a62;
  font-size: 0.8rem;
  border-top: 1px solid rgba(0,0,0,0.05);
  margin-top: 20px;
}

/* --- Prompt Terminal Vindue --- */
.prompt-window {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(840px, 94vw);
  height: min(560px, 85vh);
  background: #0f171a;
  border-radius: 20px;
  padding: 20px;
  color: #eef6f6;
  box-shadow: 0 30px 60px rgba(0,0,0,0.4);
  display: none;
  flex-direction: column;
  gap: 16px;
  z-index: 200;
}

.prompt-window.open {
  display: flex;
}

.prompt-window-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  cursor: move;
}

.prompt-window-header h3 {
  font-size: 1.3rem;
  margin-bottom: 4px;
}

.prompt-window-header p {
  color: #9fb3b7;
  font-size: 0.9rem;
}

.terminal-output {
  background: #0b1214;
  border: 1px solid #223238;
  border-radius: 12px;
  padding: 16px;
  flex: 1;
  overflow-y: auto;
  font-family: monospace;
  font-size: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.terminal-line { display: flex; gap: 12px; }
.terminal-role { min-width: 90px; font-weight: bold; font-size: 0.75rem; text-transform: uppercase; color: #647d82; }
.role-ai .terminal-role { color: #86d1d7; }
.role-underviser .terminal-role { color: #f0c188; }

.terminal-controls {
  display: flex;
  gap: 10px;
  align-items: center;
}

.ghost-btn {
  background: transparent;
  border: 1px solid #33444a;
  color: #eef6f6;
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.85rem;
}

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .content-header { flex-direction: column; gap: 12px; align-items: flex-start; }
}
