:root {
  color: #252521;
  background: #e8e7e1;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  --ink: #252521;
  --muted: #706d66;
  --line: #d4d1c7;
  --paper: #fff;
  --session: #eef3ff;
  --session-strong: #3158a5;
  --session-line: #9eb3dd;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { width: 100%; height: 100%; overflow: hidden; }
body { margin: 0; }
button, input, select, textarea { font: inherit; }

button {
  border: 1px solid #c7c4ba;
  border-radius: 0.45rem;
  background: #fff;
  color: inherit;
  cursor: pointer;
  padding: 0.55rem 0.85rem;
}
button:hover:not(:disabled) { border-color: #8d8980; background: #faf9f6; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid #9db9ed; outline-offset: 2px; }
button:disabled { cursor: default; opacity: 0.5; }
.primary-button { border-color: var(--ink); background: var(--ink); color: #fff; }
.primary-button:hover:not(:disabled) { background: #3c3c36; }
.danger-button { color: #a3271c; }

.eyebrow {
  margin: 0;
  color: #747168;
  font-size: 0.69rem;
  font-weight: 750;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.welcome { min-height: 100vh; display: grid; place-items: center; padding: 2rem; }
.welcome-card {
  width: min(31rem, 100%);
  border: 1px solid #d9d6cd;
  border-radius: 0.8rem;
  background: #fff;
  box-shadow: 0 1rem 3rem rgb(37 37 33 / 8%);
  padding: 2.4rem;
}
.welcome-card h1 { margin: 0.2rem 0 0.7rem; }
.open-form { margin-top: 2rem; }
.open-form label, .message-form label { display: block; margin-bottom: 0.45rem; font-size: 0.82rem; font-weight: 650; }
.open-controls { display: flex; gap: 0.5rem; }
.open-controls select, .message-form textarea {
  min-width: 0; border: 1px solid #c8c5bb; border-radius: 0.45rem; background: #fff; padding: 0.65rem;
}
.login-form { display: grid; gap: 0.55rem; }
.login-form label { margin-top: 0.35rem; font-size: 0.82rem; font-weight: 650; }
.login-form input {
  width: 100%;
  border: 1px solid #aaa79e;
  border-radius: 0.4rem;
  background: #fff;
  padding: 0.65rem 0.7rem;
}
.login-form button, .policy-gate-card button { margin-top: 0.8rem; width: 100%; }
.policy-checkbox { display: flex; align-items: flex-start; gap: 0.65rem; line-height: 1.45; }
.policy-checkbox input { margin-top: 0.18rem; }
.open-controls select { flex: 1; }

 .workspace { height: 100dvh; display: grid; grid-template: auto minmax(0, 1fr) / minmax(0, 1fr) 23rem; }
.topbar { grid-column: 1 / -1; display: flex; align-items: center; gap: 1rem; justify-content: space-between; padding: .8rem 1.2rem; border-bottom: 1px solid var(--line); background: #f8f7f3; }
.brand { font-weight: 750; }
.workspace-switcher { display: flex; align-items: center; gap: .6rem; min-width: 0; }
select, input, textarea { min-width: 0; border: 1px solid #c8c5bb; border-radius: .4rem; background: white; padding: .5rem; }
.workspace-switcher select { max-width: 22vw; }
.folder-area { position: relative; min-width: 0; min-height: 0; padding: 1.25rem; }
.folder { height: 100%; overflow-y: auto; border: 2px solid #cfcdc4; border-radius: .85rem; background: #f9f8f4; padding: 1.5rem; }
.folder.proposal { border-color: var(--session-strong); background: #f3f6fc; }
.folder.proposal .eyebrow { color: var(--session-strong); }
.folder-header { display: flex; align-items: start; justify-content: space-between; gap: 1rem; }
.folder-header h1 { margin: .35rem 0; overflow-wrap: anywhere; font-size: 1.65rem; }
.workspace-description { color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; max-width: 55rem; line-height: 1.5; }
.folder-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; margin: 1rem 0; }
.folder-toolbar select { max-width: 100%; }
.session-action-buttons { margin-left: auto; display: flex; flex-wrap: wrap; gap: .5rem; }
.proposal-explanation { color: #435f8c; font-size: .85rem; line-height: 1.5; }
.document-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(145px, 1fr)); gap: 1rem; padding: .75rem 0; }
.document-tile { position: relative; aspect-ratio: 1; display: flex; flex-direction: column; justify-content: space-between; align-items: start; text-align: left; padding: 1rem; border: 2px solid #dad7cf; border-radius: .7rem; box-shadow: 0 .2rem .5rem rgb(30 30 25 / 3%); }
.document-tile.changed { border-color: var(--session-strong); background: #edf3ff; }
.document-tile.deleted .tile-name { text-decoration: line-through; }
.tile-icon { font-size: 1.65rem; color: #7b7a72; }
.tile-name { font-size: .95rem; font-weight: 650; overflow: hidden; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.tile-status { font-size: .72rem; color: var(--session-strong); margin-top: .3rem; }
.new-document { border-style: dashed; background: transparent; align-items: center; justify-content: center; text-align: center; gap: .6rem; box-shadow: none; }
.new-document .tile-icon { font-size: 2rem; }
.documents-empty { color: var(--muted); font-size: .9rem; }
.editor-overlay { position: absolute; inset: 0; z-index: 5; padding: 2.25rem; background: rgb(32 42 60 / 22%); }
.editor-dialog { width: min(100%, 52rem); margin-inline: auto; height: 100%; display: flex; flex-direction: column; overflow: hidden; border: 1px solid #b9bcc4; border-radius: .8rem; background: white; box-shadow: 0 1rem 3rem rgb(20 30 50 / 22%); }
.editor-header { display: flex; align-items: start; justify-content: space-between; gap: .5rem; padding: 1rem 1.1rem .6rem; }
.editor-heading { min-width: 0; }
.editor-header h2 { margin: 0; font-size: 1.15rem; overflow-wrap: anywhere; }
.editor-header p { margin: .3rem 0 0; font-size: .78rem; color: var(--muted); }
.document-name-row { display: flex; align-items: center; gap: .6rem; padding: .4rem 1.1rem; }
.document-name-row input { flex: 1; }
.document-name-row label { font-size: .8rem; }
.editor-actions { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; padding: .5rem 1.1rem; }
.editor-actions button { font-size: .78rem; }
.save-state { flex: 1; color: var(--muted); font-size: .78rem; }
.change-legend { margin: .2rem 1.1rem .7rem; color: #4e5d77; font-size: .75rem; }
.change-legend span { display: inline-block; width: .75rem; height: .75rem; border-left: 3px solid #3158a5; background: #d9e5ff; vertical-align: -.1rem; }
#details-dialog { width: min(30rem, calc(100% - 2rem)); border: 1px solid var(--line); border-radius: .8rem; padding: 1.5rem; }
#details-dialog::backdrop { background: rgb(20 30 50 / 35%); }
.details-form { display: grid; gap: .7rem; }
.details-form h2 { margin: 0 0 .4rem; }
.surface-actions { display: flex; justify-content: flex-end; gap: .5rem; }
#welcome-logout { margin-top: 1rem; }
@media (max-width: 1050px) {
  .workspace { grid-template-columns: minmax(0, 1fr) 20rem; }
  .brand { display: none; }
  .folder-area { padding: .65rem; }
  .editor-overlay { padding: 1.25rem; }
  .folder { padding: 1rem; }
  .folder-header { flex-wrap: wrap; }
}
@media (max-width: 720px) {
  html, body { height: auto; min-height: 100%; overflow: visible; }
  .workspace { height: auto; min-height: 100dvh; grid-template: auto minmax(30rem, 65dvh) minmax(30rem, 65dvh) / minmax(0, 1fr); }
  .topbar { gap: .5rem; padding: .6rem; flex-wrap: wrap; }
  .workspace-switcher { flex-wrap: wrap; }
  .workspace-switcher select { max-width: 45vw; }
  .document-grid { grid-template-columns: repeat(auto-fill, minmax(125px, 1fr)); }
  .document-name-row { flex-wrap: wrap; }
}

.editor-stage { position: relative; flex: 1 1 0; min-width: 0; min-height: 0; overflow: hidden; }
.editor-host { position: absolute; inset: 0; width: 100%; height: 100%; min-height: 0; }
.editor-host, .toastui-editor-defaultUI { width: 100%; height: 100% !important; min-height: 0; }
.editor-host > .toastui-editor-defaultUI { display: grid !important; grid-template-rows: auto minmax(0, 1fr); }
.editor-host > .toastui-editor-defaultUI > .toastui-editor-main { display: block !important; width: 100%; height: 100% !important; min-height: 0; }
.editor-host .toastui-editor-main-container, .editor-host .toastui-editor-ww-container,
.editor-host .toastui-editor-ww-container > .toastui-editor, .editor-host .toastui-editor-contents { height: 100% !important; min-height: 0; }
.editor-host.editor-locked .toastui-editor-contents { cursor: text; }
.toastui-editor-defaultUI { border-color: #d2d0c7 !important; border-radius: 0.65rem !important; background: #fff; overflow: hidden; }
.toastui-editor-toolbar-icons.heading { width: 5rem; background-image: none; color: #333; font-size: 0.72rem; font-weight: 700; }
.toastui-editor-toolbar-icons.heading::after { content: "Headings ▾"; }
.toastui-editor-main { min-height: 0; }
.editor-host .toastui-editor-contents span[data-session-highlight-marker] {
  display: none;
}

.editor-host .toastui-editor-contents tr:has(
  [data-session-highlight-marker][data-session-changed="true"]
) > :is(th, td) {
  background: #dce7ff;
}

.editor-host .toastui-editor-contents tr:has(
  [data-session-highlight-marker][data-session-changed="true"]
) > th {
  color: #26344f;
}

.editor-host .toastui-editor-contents tr:has(
  [data-session-highlight-marker][data-session-changed="true"]
) > th > p {
  color: inherit;
}

.editor-host .toastui-editor-contents tr:has(
  [data-session-highlight-marker][data-session-changed="true"]
) > :first-child {
  position: relative;
}

.editor-host .toastui-editor-contents tr:has(
  [data-session-highlight-marker][data-session-changed="true"]
) > :first-child::before {
  content: "";
  position: absolute;
  z-index: 1;
  top: -1px;
  bottom: -1px;
  left: -1px;
  width: 4px;
  background: #3158a5;
  pointer-events: none;
}

.editor-host .toastui-editor-contents :is(
  :is(p, h1, h2, h3, h4, h5, h6):not(table *):has(> [data-session-highlight-marker][data-session-changed="true"])
) {
  position: relative;
  margin-inline: -0.55rem;
  border-radius: 0.2rem;
  background: #dce7ff;
  box-shadow: 0 0 0 0.25rem #dce7ff;
  padding-inline: 0.55rem;
}

.editor-host .toastui-editor-contents :is(
  :is(p, h1, h2, h3, h4, h5, h6):not(table *):has(> [data-session-highlight-marker][data-session-changed="true"])
)::before {
  content: "";
  position: absolute;
  top: 0.18rem;
  bottom: 0.18rem;
  left: 0;
  width: 4px;
  border-radius: 2px;
  background: #3158a5;
}

.editor-host .toastui-editor-contents :is(
  :is(p, h1, h2, h3, h4, h5, h6):not(table *):has(> [data-session-highlight-marker][data-session-changed="true"])
):has(+ :is(
  :is(p, h1, h2, h3, h4, h5, h6):not(table *):has(> [data-session-highlight-marker][data-session-changed="true"])
)) {
  margin-bottom: 0 !important;
  border-end-start-radius: 0;
  border-end-end-radius: 0;
  padding-bottom: 0.35rem;
}

.editor-host .toastui-editor-contents :is(
  :is(p, h1, h2, h3, h4, h5, h6):not(table *):has(> [data-session-highlight-marker][data-session-changed="true"])
):has(+ :is(
  :is(p, h1, h2, h3, h4, h5, h6):not(table *):has(> [data-session-highlight-marker][data-session-changed="true"])
))::before {
  bottom: -0.25rem;
  border-end-start-radius: 0;
  border-end-end-radius: 0;
}

.editor-host .toastui-editor-contents :is(
  :is(p, h1, h2, h3, h4, h5, h6):not(table *):has(> [data-session-highlight-marker][data-session-changed="true"])
) + :is(
  :is(p, h1, h2, h3, h4, h5, h6):not(table *):has(> [data-session-highlight-marker][data-session-changed="true"])
) {
  margin-top: 0 !important;
  border-start-start-radius: 0;
  border-start-end-radius: 0;
  padding-top: 0.35rem;
}

.editor-host .toastui-editor-contents :is(
  :is(p, h1, h2, h3, h4, h5, h6):not(table *):has(> [data-session-highlight-marker][data-session-changed="true"])
) + :is(
  :is(p, h1, h2, h3, h4, h5, h6):not(table *):has(> [data-session-highlight-marker][data-session-changed="true"])
)::before {
  top: -0.25rem;
  border-start-start-radius: 0;
  border-start-end-radius: 0;
}

.assistant-panel { min-height: 0; display: flex; flex-direction: column; overflow: hidden; border-left: 1px solid #cbc8be; background: #f8f7f3; }
.assistant-header { display: flex; align-items: center; justify-content: space-between; padding: 1.15rem 1rem 0.75rem; }
.assistant-header h2 { margin: 0.15rem 0 0; font-size: 1.08rem; }
.agent-status { min-height: 0; margin: 0 1rem 0.65rem; color: var(--muted); font-size: 0.78rem; }
.agent-status:not(:empty) { border: 1px solid #d5d9e2; border-radius: 0.5rem; background: #fff; padding: 0.65rem 0.75rem; }
.agent-status.failed, .agent-status.disconnected { border-color: #d9a49f; background: #fff0ee; color: #8b2118; }
.messages { flex: 1; min-height: 0; overflow-y: auto; list-style: none; margin: 0; padding: 0.4rem 1rem 1rem; }
.message { overflow-wrap: anywhere; max-width: 92%; margin: 0 0 0.7rem; border-radius: 0.65rem; background: #e7e5de; padding: 0.7rem 0.8rem; white-space: pre-wrap; }
.message.user { margin-left: auto; background: #29344d; color: #fff; }
.message-sender { display: block; margin-bottom: 0.25rem; font-size: 0.66rem; font-weight: 750; letter-spacing: 0.05em; opacity: 0.65; text-transform: uppercase; }
.conversation-empty { margin: auto 1.2rem; color: #59574f; text-align: center; }
.conversation-empty strong { font-size: 0.9rem; }
.conversation-empty p { margin: 0.35rem 0 0; color: var(--muted); font-size: 0.78rem; line-height: 1.45; }
.message-form { border-top: 1px solid #d7d4ca; padding: 1rem 1rem 2rem; }
.message-form textarea { width: 100%; max-height: 12rem; resize: vertical; }
.message-form button { width: 100%; margin-top: 0.55rem; }

.notice { position: fixed; z-index: 20; right: 1rem; bottom: 2.5rem; max-width: 28rem; border-radius: 0.5rem; background: #292925; color: #fff; box-shadow: 0 0.5rem 2rem rgb(0 0 0 / 20%); padding: 0.75rem 1rem; }
.print-document { display: none; }
.error { color: #a3271c; }

.privacy-link {
  position: fixed;
  z-index: 30;
  right: 1rem;
  bottom: 0.75rem;
  color: var(--muted);
  font-size: 0.75rem;
}

.policy-page { min-height: 100%; overflow: auto; background: #efede7; }
.policy-document {
  width: min(46rem, calc(100% - 2rem));
  margin: 3rem auto;
  border: 1px solid #d3d0c7;
  border-radius: 0.75rem;
  background: #fff;
  box-shadow: 0 0.6rem 2rem rgb(39 37 31 / 8%);
  padding: clamp(1.5rem, 5vw, 3.5rem);
}
.policy-document h1 { margin: 1.5rem 0; font-size: 2rem; }
.policy-document p { margin: 0 0 1.15rem; line-height: 1.65; }
.policy-back { color: var(--muted); font-size: 0.82rem; }

@media print {
  @page { size: auto; margin: 18mm; }
  html, body { height: auto; overflow: visible; background: #fff; }
  .welcome, .workspace, .privacy-link { display: none !important; }
  .print-document { display: block; max-width: none; color: #000; font: 11pt/1.55 Georgia, "Times New Roman", serif; }
  .print-document h1 { margin: 0 0 0.8em; font-size: 22pt; line-height: 1.15; }
  .print-document h2 { font-size: 17pt; }
  .print-document h3 { font-size: 14pt; }
  .print-document h1, .print-document h2, .print-document h3, .print-document h4 { break-after: avoid; }
  .print-document p, .print-document li { orphans: 3; widows: 3; }
  .print-document pre, .print-document blockquote, .print-document table, .print-document figure { break-inside: avoid; }
  .print-document table { width: 100%; border-collapse: collapse; }
  .print-document th, .print-document td { border: 1px solid #777; padding: 0.35em 0.5em; }
  .print-document img { max-width: 100%; }
  .print-document a { color: inherit; text-decoration: underline; }
}

#deleted-filter { display: flex; align-items: center; gap: .3rem; font-size: .8rem; color: var(--muted); }

/* The dialog sets the page width; keep modest margins within it. */
.editor-host .toastui-editor-contents { max-width: none; margin-inline: 0; padding-inline: clamp(1rem, 2.5vw, 2rem); }

#questions-dialog { max-height: 85vh; overflow-y: auto; }
#questions-fields { display: grid; gap: 1rem; }
#questions-fields label { display: grid; gap: .4rem; }
#questions-fields input[type="checkbox"] { width: 1.25rem; height: 1.25rem; }
