:root {
  --bg: #fbf5f2;
  --paper: #fffdfb;
  --ink: #4a3a46;
  --muted: #9b8792;
  --line: #f1e2e3;
  --rose: #eaa9ba;
  --rose-deep: #c56f89;
  --blush: #fce6ea;
  --lav: #e9e1fb;
  --lav-deep: #8f7bc4;
  --sage: #deeede;
  --peach: #fdeadb;
  --butter: #fbf0c9;
  --shadow: 0 10px 30px -12px rgba(197, 111, 137, .28);
  --serif: 'Fraunces', Georgia, serif;
  --sans: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --r: 18px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--sans);
  font-size: 15.5px;
  line-height: 1.55;
  color: var(--ink);
  background:
    radial-gradient(60vw 50vh at 100% 0%, var(--lav) 0%, transparent 60%),
    radial-gradient(50vw 50vh at 0% 100%, var(--peach) 0%, transparent 60%),
    radial-gradient(40vw 40vh at 60% 100%, var(--sage) 0%, transparent 65%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
em { font-style: italic; }
.brand-name em, .hello em, .login-card em { color: var(--rose-deep); }
h1, h2, h3 { font-family: var(--serif); font-weight: 500; letter-spacing: -.01em; margin: 0; }
::selection { background: var(--blush); }
* { scrollbar-width: thin; scrollbar-color: #ecd3d9 transparent; }

/* ---------- knoppen ---------- */
.btn {
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 999px;
  padding: 8px 16px;
  font-weight: 700;
  font-size: 14px;
  white-space: nowrap;
  transition: transform .12s, box-shadow .12s, background .12s;
}
.btn:hover { background: #fff; box-shadow: 0 4px 14px -6px rgba(197, 111, 137, .4); transform: translateY(-1px); }
.btn.primary { background: linear-gradient(135deg, #efb3c2, #d98aa1); border-color: transparent; color: #fff; }
.btn.primary:hover { background: linear-gradient(135deg, #eba6b8, #d07c95); }
.btn.danger { background: #d9667c; border-color: transparent; color: #fff; }
.btn.accent { background: var(--lav); border-color: transparent; color: #5f4d94; }
.btn.small { padding: 5px 13px; font-size: 13px; }
.btn.wide { width: 100%; }
.link { border: 0; background: none; padding: 4px 6px; color: var(--muted); font-size: 13px; font-weight: 600; border-radius: 8px; }
.link:hover { color: var(--rose-deep); background: var(--blush); }
.row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.row.end { justify-content: flex-end; }

/* ---------- raamwerk ---------- */
.app { display: grid; grid-template-columns: 290px minmax(0, 1fr); height: 100dvh; }
.side {
  display: flex; flex-direction: column; min-height: 0;
  margin: 14px 0 14px 14px; padding: 18px 14px 10px;
  background: rgba(255, 253, 251, .78);
  backdrop-filter: blur(14px);
  border: 1px solid #fff;
  border-radius: 26px;
  box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 6px 16px; }
.brand-name { font-family: var(--serif); font-size: 21px; font-weight: 500; line-height: 1.1; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; background: var(--blush); border-radius: 999px; padding: 4px; margin-bottom: 14px; }
.tab { border: 0; background: none; border-radius: 999px; padding: 7px 0; font-weight: 700; font-size: 14px; color: #a9788a; }
.tab.active { background: #fff; color: var(--rose-deep); box-shadow: 0 2px 8px -3px rgba(197, 111, 137, .45); }
.side-body { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 10px; border-radius: 16px; }
.side-body.dropping { outline: 2px dashed var(--rose); outline-offset: 4px; background: var(--blush); }
.side-foot { padding-top: 8px; border-top: 1px solid var(--line); margin-top: 8px; text-align: center; }
.doc-actions { display: flex; gap: 6px; }
.doc-actions .btn { padding: 8px 6px; font-size: 13px; flex: 1; min-width: 0; }
.drop-hint { font-size: 12px; color: var(--muted); text-align: center; padding: 4px; }

.list, .tree { list-style: none; margin: 0; padding: 0; flex: 1; min-height: 0; overflow-y: auto; }
.row-item { display: flex; align-items: center; border-radius: 12px; padding: 0 4px 0 8px; margin: 1px 0; }
.row-item:hover { background: rgba(252, 230, 234, .65); }
.row-item.active { background: var(--blush); }
.row-item.active .nm, .row-item.active .row-main { color: var(--rose-deep); font-weight: 700; }
.row-item.current-dir .nm { text-decoration: underline; text-decoration-color: var(--rose); text-underline-offset: 3px; }
.row-main {
  flex: 1; min-width: 0; border: 0; background: none; text-align: left; padding: 8px 4px;
  display: flex; gap: 8px; align-items: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14.5px;
}
li .row-main { display: block; }
.row-main .nm { overflow: hidden; text-overflow: ellipsis; }
.row-main .ico { font-size: 15px; flex: none; }
.row-more { border: 0; background: none; color: var(--muted); border-radius: 8px; width: 26px; height: 26px; opacity: 0; flex: none; font-size: 16px; line-height: 1; }
.row-item:hover .row-more, .row-more:focus { opacity: 1; }
.row-more:hover { background: #fff; color: var(--rose-deep); }
.tree-empty { color: var(--muted); font-size: 14px; padding: 14px 8px; text-align: center; }

.main { position: relative; min-width: 0; min-height: 0; padding: 14px; }
.view { height: 100%; min-height: 0; }
.menu-toggle { display: none; position: absolute; top: 20px; left: 20px; z-index: 5; padding: 6px 12px; }

/* ---------- chat ---------- */
.chatpane { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.chatpane.big { max-width: 820px; margin: 0 auto; }
.msgs { flex: 1; min-height: 0; overflow-y: auto; padding: 18px 6px; display: flex; flex-direction: column; gap: 16px; }
.msg { display: flex; gap: 10px; align-items: flex-start; }
.msg.user { justify-content: flex-end; }
.avatar { width: 30px; height: 30px; flex: none; margin-top: 4px; }
.bubble { max-width: min(86%, 680px); border-radius: var(--r); padding: 11px 16px; overflow-wrap: anywhere; }
.msg.user .bubble { background: linear-gradient(135deg, #f6cbd5, #eeb5c4); color: #5a3443; border-bottom-right-radius: 6px; white-space: pre-wrap; }
.msg.assistant .bubble { background: var(--paper); border: 1px solid #fff; box-shadow: 0 6px 20px -12px rgba(120, 90, 110, .35); border-top-left-radius: 6px; flex: 0 1 auto; min-width: 0; }
.prose > :first-child { margin-top: 0; }
.prose > :last-child { margin-bottom: 0; }
.prose p, .prose ul, .prose ol { margin: .55em 0; }
.prose h1, .prose h2, .prose h3 { margin: .9em 0 .35em; font-size: 1.15em; }
.prose a { color: var(--rose-deep); }
.prose code { background: var(--blush); border-radius: 6px; padding: 1px 5px; font-size: .9em; }
.prose pre { background: #faf0f1; border-radius: 12px; padding: 12px; overflow-x: auto; }
.prose pre code { background: none; padding: 0; }
.prose blockquote { margin: .6em 0; padding: 2px 14px; border-left: 3px solid var(--rose); color: #7a6672; }
.prose table { border-collapse: collapse; display: block; overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--line); padding: 5px 10px; text-align: left; }
.prose th { background: var(--blush); }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--sage); color: #4f7355; border-radius: 999px; padding: 3px 12px; font-size: 12.5px; font-weight: 700; margin: 5px 6px 5px 0; }
.chip::before { content: '✿'; font-size: 11px; }
.note { font-size: 13px; margin-top: 6px; }
.note.error { color: #b8475f; background: #fdecef; border-radius: 10px; padding: 8px 12px; }
.note.muted { color: var(--muted); font-style: italic; }
.dots { display: inline-flex; gap: 5px; padding: 6px 0 2px; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--rose); animation: bob 1.1s infinite ease-in-out; }
.dots i:nth-child(2) { animation-delay: .15s; background: #c9b8ee; }
.dots i:nth-child(3) { animation-delay: .3s; background: #a9d1b0; }
@keyframes bob { 0%, 80%, 100% { transform: translateY(0); opacity: .5; } 40% { transform: translateY(-5px); opacity: 1; } }

.composer {
  display: flex; align-items: flex-end; gap: 8px;
  background: var(--paper); border: 1px solid #fff; border-radius: 26px;
  padding: 8px 8px 8px 18px; box-shadow: var(--shadow);
}
.composer:focus-within { box-shadow: 0 0 0 3px var(--blush), var(--shadow); }
.composer textarea { flex: 1; border: 0; outline: 0; resize: none; background: none; padding: 8px 0; max-height: 180px; line-height: 1.45; }
.composer textarea::placeholder { color: #c2aeb7; }
.send { flex: none; width: 40px; height: 40px; border-radius: 50%; border: 0; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, #efb3c2, #d07c95); transition: transform .12s; }
.send:hover { transform: scale(1.06); }
.send.stop { background: var(--lav-deep); font-size: 13px; }

.hello { margin: auto; text-align: center; max-width: 560px; padding: 20px; }
.hello h1 { font-size: clamp(30px, 4.5vw, 44px); margin: 14px 0 8px; }
.hello p { color: var(--muted); margin: 0 0 20px; }
.hello.small { margin: auto 0; padding: 10px 4px; }
.hello.small p { font-size: 14px; margin-bottom: 12px; }
.suggest { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.pill { border: 1px solid #fff; background: rgba(255, 255, 255, .8); border-radius: 999px; padding: 8px 15px; font-size: 14px; font-weight: 600; box-shadow: 0 4px 14px -8px rgba(197, 111, 137, .5); transition: transform .12s, background .12s; }
.pill:nth-child(4n+1) { background: var(--blush); }
.pill:nth-child(4n+2) { background: var(--lav); }
.pill:nth-child(4n+3) { background: var(--sage); }
.pill:nth-child(4n+4) { background: var(--butter); }
.pill:hover { transform: translateY(-2px); }

/* ---------- documenten ---------- */
.docs-view { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 14px; }
.docs-view.chat-off { grid-template-columns: minmax(0, 1fr); }
.docs-view.chat-off .doc-chat { display: none; }
.doc-area, .doc-chat {
  min-height: 0; min-width: 0; display: flex; flex-direction: column;
  background: var(--paper); border: 1px solid #fff; border-radius: 26px; box-shadow: var(--shadow); overflow: hidden;
}
.doc-chat { background: rgba(255, 250, 250, .85); padding: 0 12px 12px; }
.doc-chat .msgs { padding: 14px 2px; }
.doc-chat .bubble { max-width: 100%; font-size: 14.5px; }
.doc-chat .avatar { display: none; }
.doc-chat .composer { box-shadow: none; border-color: var(--line); }
.pane-head { display: flex; align-items: center; gap: 8px; padding: 14px 4px 10px; border-bottom: 1px solid var(--line); font-family: var(--serif); font-size: 18px; }
.pane-head span { flex: 1; }
.close-chat { display: none; }
.doc-head { display: flex; align-items: center; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.doc-title { font-family: var(--serif); font-size: 21px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-status { font-size: 12.5px; color: var(--muted); flex: 1; white-space: nowrap; }
.doc-head-actions { display: flex; gap: 6px; }
.doc-body { flex: 1; min-height: 0; position: relative; }
.doc-body > * { height: 100%; }
#editor-wrap { height: 100%; }
#doc-frame { width: 100%; border: 0; display: block; }
#plain-editor { width: 100%; border: 0; outline: 0; resize: none; padding: 24px 32px; background: none; font-family: ui-monospace, Menlo, monospace; font-size: 13.5px; line-height: 1.6; display: block; }
.doc-image { display: grid; place-items: center; padding: 24px; overflow: auto; }
.doc-image img { max-width: 100%; border-radius: 14px; box-shadow: var(--shadow); }
.doc-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 8px; padding: 30px; color: var(--muted); }
.doc-empty h2 { color: var(--ink); font-size: 26px; overflow-wrap: anywhere; }
.doc-empty p { max-width: 400px; margin: 0 0 10px; }
.doc-busy {
  position: absolute; inset: 0; height: auto; z-index: 40;
  display: flex; align-items: flex-end; justify-content: center; gap: 10px; padding-bottom: 28px;
  background: linear-gradient(to bottom, rgba(255, 253, 251, .35), rgba(255, 253, 251, .8));
  font-weight: 700; color: var(--rose-deep);
}

/* Toast UI editor in werkplek-stijl */
.toastui-editor-defaultUI { border: 0 !important; border-radius: 0; font-family: var(--sans); }
.toastui-editor-defaultUI-toolbar { background: #fff8f8 !important; border-bottom: 1px solid var(--line) !important; padding: 0 14px !important; }
.toastui-editor-toolbar { background: transparent !important; }
.toastui-editor-toolbar-divider { background: var(--line) !important; }
.toastui-editor-defaultUI-toolbar button { border-radius: 8px !important; border: 0 !important; }
.toastui-editor-defaultUI-toolbar button:not(:disabled):hover { background-color: var(--blush) !important; border: 0 !important; }
.toastui-editor-defaultUI .ProseMirror { padding: 28px clamp(20px, 6%, 64px) 80px !important; max-width: 860px; margin: 0 auto; }
.toastui-editor-contents { font-family: var(--sans) !important; font-size: 16px !important; color: var(--ink) !important; line-height: 1.7; }
.toastui-editor-contents p { color: var(--ink) !important; margin: 0 0 .8em !important; }
.toastui-editor-contents h1, .toastui-editor-contents h2, .toastui-editor-contents h3, .toastui-editor-contents h4 {
  font-family: var(--serif) !important; font-weight: 500 !important; color: var(--ink) !important; border: 0 !important; padding: 0 !important;
}
.toastui-editor-contents h1 { font-size: 34px !important; line-height: 1.2 !important; margin: 8px 0 18px !important; }
.toastui-editor-contents h2 { font-size: 24px !important; line-height: 1.3 !important; margin: 28px 0 10px !important; }
.toastui-editor-contents h3 { font-size: 19px !important; margin: 22px 0 8px !important; }
.toastui-editor-contents a { color: var(--rose-deep) !important; }
.toastui-editor-contents blockquote { border-left: 3px solid var(--rose) !important; }
.toastui-editor-contents table th { background: var(--rose) !important; border-color: var(--line) !important; }
.toastui-editor-contents table td { border-color: var(--line) !important; }
.toastui-editor-contents ul > li::before { background-color: var(--rose) !important; }
.toastui-editor-contents hr { border-top-color: var(--line) !important; }
.toastui-editor-popup { border-radius: 14px !important; border-color: var(--line) !important; box-shadow: var(--shadow) !important; }

/* ---------- menu, modal, toast ---------- */
.menu { position: fixed; z-index: 60; background: #fff; border-radius: 14px; padding: 6px; box-shadow: 0 14px 40px -10px rgba(90, 60, 80, .35); min-width: 190px; display: flex; flex-direction: column; }
.menu-item { border: 0; background: none; text-align: left; padding: 8px 12px; border-radius: 9px; font-size: 14px; font-weight: 600; }
.menu-item:hover { background: var(--blush); }
.menu-item.danger { color: #c2536a; }
.modal-back { position: fixed; inset: 0; z-index: 80; background: rgba(120, 90, 110, .25); backdrop-filter: blur(4px); display: grid; place-items: center; padding: 20px; }
.modal { background: var(--paper); border-radius: 24px; padding: 24px; width: min(420px, 100%); box-shadow: 0 30px 80px -20px rgba(90, 60, 80, .45); }
.modal h3 { font-size: 22px; margin-bottom: 6px; }
.modal p { color: var(--muted); margin: 0 0 12px; font-size: 14.5px; }
.modal input, .login-card input {
  width: 100%; border: 1.5px solid var(--line); border-radius: 14px; padding: 11px 14px; outline: 0; background: #fff; margin: 6px 0 16px;
}
.modal input:focus, .login-card input:focus { border-color: var(--rose); box-shadow: 0 0 0 3px var(--blush); }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 90; background: #5a4553; color: #fff; padding: 10px 20px; border-radius: 999px; font-size: 14px; font-weight: 600; box-shadow: 0 10px 30px -10px rgba(0, 0, 0, .4); }

/* ---------- login ---------- */
.login-body { display: grid; place-items: center; padding: 20px; }
.login-card { background: rgba(255, 253, 251, .86); backdrop-filter: blur(14px); border: 1px solid #fff; border-radius: 30px; padding: 40px 34px 30px; width: min(400px, 100%); text-align: center; box-shadow: var(--shadow); }
.login-card h1 { font-size: 38px; margin: 10px 0 6px; }
.login-card p { color: var(--muted); margin: 0 0 18px; }
.login-card .btn { width: 100%; padding: 12px; font-size: 15px; }
.login-error { color: #b8475f; font-size: 14px; min-height: 22px; margin-top: 12px; }

/* ---------- smal scherm ---------- */
@media (max-width: 1100px) {
  .docs-view { grid-template-columns: minmax(0, 1fr) 330px; }
  .doc-head-actions #doc-download { display: none; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; z-index: 50; inset: 0 auto 0 0; width: min(300px, 86vw); margin: 10px; transform: translateX(-115%); transition: transform .22s; background: var(--paper); }
  .app.side-open .side { transform: none; }
  .menu-toggle { display: block; }
  .main { padding: 10px; }
  .chatpane.big .msgs { padding-top: 54px; }
  .doc-head { padding-left: 64px; }
  .doc-head-actions #doc-word { display: none; }
  .docs-view, .docs-view.chat-off { grid-template-columns: minmax(0, 1fr); }
  .doc-chat { display: none; position: fixed; inset: 10px; z-index: 45; background: var(--paper); }
  .docs-view.chat-on .doc-chat { display: flex; }
  .close-chat { display: inline-block; }
  .row-more { opacity: 1; }
}
