/* Ink — write app dark theme: near-black surfaces, muted text, low glare */
[data-theme="ink"] {
    --bg1: #0c0c0e;
    --c1: #dedee3;
    --bg2: #131316;
    --c2: #a3a3aa;
    --bg3: #4d6b5c;
    --c3: #dce2de;
    --input-bg: #101012;
    --border: rgba(255, 255, 255, 0.07);
    --pastel-1: #181a1e;
    --pastel-2: #1a1c20;
    --pastel-3: #221a1c;
    --pastel-4: #161c19;
    --pastel-5: #1c1a16;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.45);
    --shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
    --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.65);
    --shadow-glow:
        0 0 24px rgba(77, 107, 92, 0.12), 0 12px 32px rgba(0, 0, 0, 0.5);
    --ripple-color: rgba(196, 196, 200, 0.18);
    --bg-glow-1: rgba(77, 107, 92, 0.06);
    --bg-glow-2: rgba(60, 60, 68, 0.05);
    --bg-glow-3: rgba(40, 40, 48, 0.04);
    --gradient-2: #3d5549;
    --br: 10px;
    --overlay-start: rgba(0, 0, 0, 0.55);
    --overlay-end: rgba(0, 0, 0, 0.75);
}

[data-theme="ink"] .dsg-bg-glow::before {
    filter: blur(20px);
    opacity: 0.55;
}

[data-theme="ink"] .dsg-nav-title {
    background: none;
    -webkit-text-fill-color: var(--c1);
    color: var(--c1);
    font-weight: 700;
}

[data-theme="ink"] .dsg-card-header {
    background: linear-gradient(135deg, var(--pastel-1), var(--pastel-2));
    color: var(--c1);
    font-weight: 600;
}

[data-theme="ink"] .dsg-btn-contrast {
    background: linear-gradient(135deg, #3d5549, var(--bg3));
    color: var(--c3);
    --ripple-color: rgba(220, 226, 222, 0.25);
}

[data-theme="ink"] .dsg-btn-secondary {
    background: var(--pastel-1);
    color: var(--c1);
    border: 1px solid var(--border);
}

[data-theme="ink"] .dsg-btn-secondary:hover {
    background: var(--pastel-2);
}

[data-theme="ink"] .dsg-snackbar {
    background: var(--bg2);
    color: var(--c1);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

[data-theme="ink"] .dsg-link,
[data-theme="ink"] a {
    color: #ffffff;
    text-decoration: none;
}

[data-theme="ink"] .dsg-link:hover,
[data-theme="ink"] a:hover {
    color: #e8e8e8;
}

[data-theme="ink"] .dsg-dialog {
    background: rgba(0, 0, 0, 0.72);
    backdrop-filter: blur(6px);
}

[data-theme="ink"] .dsg-input:focus {
    border-color: rgba(77, 107, 92, 0.55);
    box-shadow: 0 0 0 4px rgba(77, 107, 92, 0.12);
}

[data-theme="ink"] h1,
[data-theme="ink"] h2,
[data-theme="ink"] h3 {
    -webkit-text-fill-color: var(--c1);
    color: var(--c1);
    background: none;
}

[data-theme="ink"] #toast-editor .toastui-editor-defaultUI {
    background: var(--bg2);
    border-color: var(--border);
}

[data-theme="ink"] #toast-editor .toastui-editor-defaultUI-toolbar {
    background: var(--bg1);
    border-color: var(--border);
}

[data-theme="ink"] #toast-editor .toastui-editor-mode-switch,
[data-theme="ink"] #toast-editor .ProseMirror {
    background: var(--bg2);
    color: var(--c1);
}

[data-theme="ink"] #toast-editor .toastui-editor-defaultUI-toolbar button {
    border-color: var(--border);
    background-color: transparent;
}

[data-theme="ink"]
    #toast-editor
    .toastui-editor-defaultUI-toolbar
    button:not(:disabled):hover {
    background-color: var(--pastel-1);
    border-color: var(--border);
}

[data-theme="ink"] #toast-editor .toastui-editor-toolbar-icons {
    filter: invert(0.88);
}

[data-theme="ink"] #toast-editor .toastui-editor-toolbar-divider {
    background-color: var(--border);
}

[data-theme="ink"] #toast-editor .toastui-editor-contents,
[data-theme="ink"] #toast-editor .toastui-editor-ww-container {
    background: var(--bg2);
}

[data-theme="ink"] #toast-editor .ProseMirror p,
[data-theme="ink"] #toast-editor .toastui-editor-contents p {
    color: var(--c1);
}

#toast-editor .toastui-editor-defaultUI {
    background: var(--bg2) !important;
    border-color: var(--border) !important;
    color: var(--c1) !important;
}

#toast-editor .toastui-editor-defaultUI-toolbar {
    background: var(--bg1) !important;
    border-color: var(--border) !important;
}

#toast-editor .toastui-editor-main,
#toast-editor .toastui-editor,
#toast-editor .toastui-editor-ww-container,
#toast-editor .toastui-editor-md-container,
#toast-editor .toastui-editor-md-preview,
#toast-editor .toastui-editor-contents,
#toast-editor .ProseMirror {
    background: var(--bg2) !important;
    color: var(--c1) !important;
}

#toast-editor .toastui-editor-contents,
#toast-editor .toastui-editor-contents p,
#toast-editor .toastui-editor-contents li,
#toast-editor .toastui-editor-contents h1,
#toast-editor .toastui-editor-contents h2,
#toast-editor .toastui-editor-contents h3,
#toast-editor .toastui-editor-contents h4,
#toast-editor .toastui-editor-contents h5,
#toast-editor .toastui-editor-contents h6,
#toast-editor .ProseMirror p {
    color: var(--c1) !important;
}

#toast-editor .toastui-editor-defaultUI-toolbar button {
    border-color: var(--border) !important;
    background-color: transparent !important;
}

#toast-editor .toastui-editor-defaultUI-toolbar button:not(:disabled):hover {
    background-color: var(--pastel-1) !important;
    border-color: var(--border) !important;
}

#toast-editor .toastui-editor-toolbar-divider {
    background-color: var(--border) !important;
}

[data-theme="ink"] #toast-editor .toastui-editor-toolbar-icons,
[data-theme="dark"] #toast-editor .toastui-editor-toolbar-icons,
[data-theme="navy"] #toast-editor .toastui-editor-toolbar-icons {
    filter: invert(0.88);
}

.write-app .dsg-nav {
    margin-bottom: 0;
    padding: 0;
}
.write-app {
    height: 100vh;
    overflow: hidden;
}
.write-app [hidden] {
    display: none !important;
}
.write-app .dsg-nav-container {
    max-width: none;
    min-height: 2.2rem;
    border-radius: 0;
    padding: 0.25rem 0.6rem;
    gap: 0.5rem;
}
.write-app .dsg-nav-container .dsg-btn {
    padding: 0.2rem 0.6rem;
    font-size: 0.82rem;
    width: auto;
    max-width: none;
}
.write-app .dsg-nav-container .dsg-link,
.write-app .dsg-nav-container .dsg-link-secondary {
    font-size: 0.82rem;
}
.write-app .dsg-nav-container .dsg-menu-toggle {
    padding: 0.3rem;
}
.write-app .dsg-nav-container .dsg-menu-toggle span {
    width: 18px;
    height: 2px;
    margin: 3px 0;
}
.write-nav .dsg-nav-title {
    text-decoration: none;
    font-size: 1rem;
    font-weight: 700;
}
.write-nav .write-back-title::before {
    content: "← ";
}
.write-nav .dsg-nav-menu {
    flex: 1;
    justify-content: flex-end;
    gap: 0.45rem;
}
.write-sidebar-toggle {
    width: 1.6rem;
    height: 1.6rem;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--br);
    background: var(--pastel-1);
    color: var(--c1);
    cursor: pointer;
    font: inherit;
    font-weight: 700;
}
.write-sidebar-toggle[hidden] {
    display: none;
}
.write-sidebar-toggle:hover,
.write-sidebar-toggle[aria-pressed="true"] {
    background: var(--pastel-2);
}
.write-sync-controls {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}
.write-sync-controls .dsg-btn {
    white-space: nowrap;
}
.write-tabs {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-wrap: wrap;
    margin-left: auto;
}
.write-tab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: auto;
    min-width: 0;
    padding: 0.2rem 0.5rem;
    border: 1px solid transparent;
    border-radius: var(--br);
    background: transparent;
    color: var(--c2);
    text-decoration: none;
    font: inherit;
    line-height: 1;
    cursor: pointer;
}
.write-tab:hover,
.write-tab.active {
    background: var(--pastel-1);
    color: var(--c1);
    border-color: var(--border);
}
#project-more {
    display: inline-flex;
}
#project-more[hidden],
#project-more-mobile[hidden] {
    display: none !important;
}
.write-more-menu .dsg-dropdown-menu {
    min-width: 10rem;
}
.write-more-menu .dsg-dropdown-item {
    color: var(--c1);
    text-decoration: none;
    font-size: 0.92rem;
}
.write-more-menu .dsg-dropdown-item::after {
    display: none;
}
.write-more-menu .write-account-name {
    color: var(--c2);
    cursor: default;
    font-weight: 700;
}
.write-more-menu .write-account-name:hover {
    background: transparent;
}
.write-logout-form {
    display: inline;
    margin: 0;
}
.write-link-button {
    appearance: none;
    border: 0;
    background: transparent;
    padding: 0;
    font: inherit;
    cursor: pointer;
}
.write-profile-picker {
    margin-top: 0.8rem;
    display: grid;
    gap: 0.45rem;
    max-width: 26rem;
}
.write-profile-picker-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}
.write-profile-picker-row select {
    min-width: 0;
}
.write-profile-picker .dsg-btn {
    justify-self: start;
}
.write-profile-picker-compact {
    margin-top: 0;
    width: min(28rem, 42vw);
}
.write-profile-picker-compact p {
    font-size: 0.85rem;
    max-width: 26rem;
}
.write-profile-rename {
    min-width: 2.6rem;
    padding-inline: 0.75rem;
}
.write-tab-manuscript {
    border-color: rgba(77, 107, 92, 0.55);
    background: rgba(77, 107, 92, 0.12);
    color: #b8c8bc;
}
.write-tab-manuscript:hover,
.write-tab-manuscript.active {
    border-color: rgba(120, 156, 136, 0.75);
    background: rgba(77, 107, 92, 0.24);
    color: var(--c3);
}
.write-tabs-mobile {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
    margin: 0;
    gap: 0.2rem;
}
#write-mobile-panel {
    width: min(20rem, 86vw);
}
#write-mobile-panel .dsg-panel-header {
    padding: 0.65rem;
}
#write-mobile-panel .dsg-panel-header .close-panel {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 2.25rem;
    width: 2.25rem !important;
    max-width: 2.25rem;
    height: 2.25rem;
    padding: 0 !important;
    border-radius: 999px;
    font-size: 1.15rem;
    line-height: 1;
}
#write-mobile-panel .dsg-panel-content {
    padding: 0.65rem;
    gap: 0.45rem;
}
#write-mobile-panel .dsg-btn,
#write-mobile-panel .write-tab {
    width: 100%;
    max-width: none;
    padding: 0.55rem 0.7rem;
    text-align: left;
    justify-content: flex-start;
}
#write-mobile-panel .write-more-menu,
#write-mobile-panel #project-more-mobile,
#write-mobile-panel .write-more-menu .dsg-dropdown-menu {
    width: 100%;
}
#write-mobile-panel .write-more-menu .dsg-dropdown-menu {
    position: static;
    margin-top: 0.2rem;
    box-shadow: none;
    background: var(--bg1);
}
#write-mobile-panel .write-more-menu .dsg-dropdown-item {
    justify-content: flex-start;
}

.write-layout {
    display: grid;
    grid-template-columns:
        var(--write-sidebar-width, minmax(260px, 320px))
        minmax(0, 1fr);
    height: calc(100vh - 36px);
    max-height: calc(100vh - 36px);
    overflow: hidden;
}
.write-sidebar-collapsed .write-layout {
    grid-template-columns: minmax(0, 1fr);
}
.write-sidebar-collapsed.write-agent-pinned .write-layout {
    grid-template-columns: minmax(0, 1fr) var(--write-agent-width, 380px);
}
.write-sidebar-collapsed .write-sidebar {
    display: none;
}
.write-no-sidebar .write-sidebar {
    display: none !important;
}
#agent-pin {
    min-width: 4rem;
}
.write-agent-pinned .write-layout {
    grid-template-columns:
        var(--write-sidebar-width, minmax(260px, 320px))
        minmax(0, 1fr) var(--write-agent-width, 380px);
}
.write-sidebar {
    position: relative;
    z-index: 100;
    height: calc(100vh - 36px);
    max-height: calc(100vh - 36px);
    padding: 0.65rem;
    overflow: auto;
    overscroll-behavior: contain;
    border-right: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.12);
}
.write-sidebar-resize {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 12px;
    cursor: col-resize;
    z-index: 5;
}
.write-sidebar-resize::after {
    content: "";
    position: absolute;
    top: 0;
    right: 4px;
    bottom: 0;
    width: 1px;
    background: rgba(255, 255, 255, 0.14);
}
.write-sidebar-resize:hover::after,
.write-sidebar-resize:active::after {
    width: 2px;
    background: var(--bg3);
}
.write-resizing-sidebar,
.write-resizing-sidebar * {
    cursor: col-resize !important;
    user-select: none;
}
.write-main {
    width: 100%;
    height: 100%;
    max-width: none;
    margin: 0;
    padding: 0.35rem;
    overflow: auto;
    overscroll-behavior: contain;
    min-width: 0;
    box-sizing: border-box;
}
.write-agent-panel {
    width: var(--write-agent-width, 380px);
    max-width: 92vw;
    z-index: 10001;
}
.write-agent-panel:not(.active) {
    pointer-events: none;
}
.write-agent-panel.active {
    pointer-events: auto;
}
.write-agent-panel.pinned {
    position: relative;
    inset: auto;
    transform: none;
    width: auto;
    max-width: none;
    height: calc(100vh - 36px);
    max-height: calc(100vh - 36px);
    border-left: 1px solid var(--border);
    box-shadow: none;
}
.write-agent-panel.pinned:not(.active) {
    display: none;
}
.write-agent-resize {
    display: none;
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 6px;
    cursor: col-resize;
}
.write-agent-panel.pinned .write-agent-resize {
    display: block;
}

.write-sidebar .dsg-aside {
    max-width: none;
    border: 0;
    border-radius: 0;
    background: transparent;
    overflow: visible;
}
.write-sidebar-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    padding-bottom: 0.45rem;
    border-bottom: 1px solid var(--border);
}
.write-sidebar-header strong {
    min-width: 0;
}
.write-sidebar-header-actions {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.2rem;
    white-space: nowrap;
}
.write-sidebar-header .dsg-btn,
.write-toolbar .dsg-btn {
    width: auto;
    min-width: 0;
    padding: 0.45rem 0.7rem;
}
.write-sidebar .dsg-btn {
    width: auto;
    min-width: 0;
    max-width: none;
    padding: 0.32rem 0.48rem;
    border-radius: 999px;
    font-size: 0.85rem;
}
.write-sidebar-header-actions .dsg-btn {
    padding: 0.22rem 0.42rem;
    font-size: 0.76rem;
    box-shadow: none;
}
.write-binder-actions {
    display: flex;
    gap: 0.35rem;
    align-items: center;
    margin-bottom: 0.5rem;
}
.write-binder-actions strong {
    flex: 1;
}
.write-binder-list {
    list-style: none;
    padding: 0;
    margin: 0.25rem 0;
}
.write-binder-list li {
    margin: 0.2rem 0;
}
.write-binder-list a {
    text-decoration: none;
}
.write-binder-list a:hover {
    text-decoration: underline;
}
.write-sidebar-link {
    display: block;
    padding: 0.42rem 0.5rem;
    border-radius: var(--br);
    overflow: hidden;
    text-overflow: ellipsis;
}
.write-sidebar-link.active {
    background: var(--pastel-1);
    color: var(--c1);
}
.write-sidebar-link small {
    display: block;
    margin-top: 0.15rem;
    color: var(--c2);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.write-binder-title {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.write-drag-handle {
    cursor: grab;
}
.write-manuscript-list {
    display: grid;
    gap: 0.45rem;
}
.write-act-block {
    padding: 0.45rem 0;
    border-bottom: 1px solid var(--border);
    background: transparent;
}
.write-act-block:last-child {
    border-bottom: 0;
}
.write-act-row,
.write-chapter-row {
    display: grid;
    grid-template-columns: 2rem 2rem minmax(0, 1fr) auto;
    gap: 0.35rem 0.5rem;
    align-items: start;
    min-width: 0;
}
.write-chapter-row {
    grid-template-columns: 2rem minmax(0, 1fr) auto;
}
.write-act-row .dsg-btn,
.write-chapter-row .dsg-btn {
    padding: 0.25rem 0.4rem;
    width: auto;
    min-width: 0;
}
.write-act-row .write-drag-handle,
.write-chapter-row .write-drag-handle {
    width: 1.9rem;
    height: 1.9rem;
    padding: 0;
    flex: 0 0 auto;
}
.write-act-toggle {
    width: 1.9rem;
    height: 1.9rem;
    padding: 0 !important;
}
.write-sidebar-title {
    min-width: 0;
    overflow: hidden;
}
.write-sidebar-title .write-row-kind {
    display: block;
    color: var(--c2);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    line-height: 1.2;
}
.write-sidebar-title .write-binder-title,
.write-sidebar-title a.write-binder-title {
    display: block;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.write-row-actions {
    grid-column: 4;
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
    min-width: 0;
}
.write-chapter-row .write-row-actions {
    grid-column: 3;
}
.write-order-btn {
    display: none;
}
.write-chapter-row[draggable="true"],
.write-act-row[draggable="true"] {
    cursor: default;
}
.write-chapter-row {
    padding: 0.35rem 0 0.35rem 1rem;
}
.write-chapter-row .write-row-kind {
    color: #9aab9f;
}

.write-chapter-header {
    margin-bottom: 0.15rem;
}
.write-chapter-title-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    min-width: 0;
    width: 100%;
}
.write-chapter-title-row h2 {
    flex: 1 1 auto;
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.2;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.write-chapter-title-row .dsg-btn {
    flex: 0 0 auto;
    width: auto;
    min-width: 0;
    padding: 0.2rem 0.45rem;
    font-size: 0.82rem;
    box-shadow: none;
}
.write-toolbar {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex-wrap: wrap;
}
.write-editor-toolbar-item {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: auto;
    min-width: max-content;
    height: 100%;
    padding: 0;
}
.toastui-editor-toolbar-item:has(.write-editor-toolbar-item) {
    width: auto !important;
    min-width: max-content !important;
    height: 32px !important;
    margin: 0 0.04rem !important;
    padding: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    overflow: visible !important;
}
.write-editor-toolbar-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 24px;
    width: auto !important;
    min-width: max-content !important;
    padding: 0 1rem !important;
    box-sizing: content-box;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--pastel-1) !important;
    color: var(--c1) !important;
    box-shadow: none;
    font: inherit;
    font-size: 0.76rem;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    opacity: 1 !important;
    white-space: nowrap;
}
.write-editor-toolbar-btn:hover {
    background: var(--pastel-2) !important;
    color: var(--c1) !important;
}
#toast-editor .toastui-editor-defaultUI-toolbar {
    min-height: 2.4rem;
}
.write-status {
    margin-top: 0.25rem;
    font-size: 0.8rem;
    color: var(--c2);
}

.write-agent-panel .dsg-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 0.65rem;
    flex-wrap: wrap;
}
.write-agent-header-actions {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.write-agent-header-actions:last-child {
    flex-shrink: 0;
}
.write-agent-tier {
    max-width: 90px;
    font-size: 0.72rem;
    padding: 0.18rem 0.3rem;
    border-radius: 999px;
}
.write-agent-thinking {
    opacity: 0.6;
    font-style: italic;
}
.write-agent-thinking-dots {
    display: inline-block;
    min-width: 1.2em;
}
.write-agent-tier-note {
    text-align: center;
    font-size: 0.78rem;
    color: var(--muted);
    padding: 0.35rem 0;
    opacity: 0.85;
}
.write-agent-panel .dsg-panel-header .dsg-btn {
  width: auto;
  min-width: 0;
  padding: 0.32rem 0.7rem;
  border-radius: 999px;
  font-size: 0.82rem;
  box-shadow: none;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.write-agent-panel .dsg-panel-header .dsg-btn.active {
  background: var(--c1);
  color: var(--bg1);
}

#agent-panel .dsg-panel-content {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.write-agent-content {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    padding: 0.65rem 0.65rem 0.95rem;
    gap: 0.5rem;
}
#agent-context {
    flex: 0 0 auto;
    font-size: 0.76rem;
    color: var(--c2);
    line-height: 1.2;
}
.write-agent-title {
    flex: 0 0 auto;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--c1);
    line-height: 1.3;
    margin-bottom: 0.1rem;
}
.write-agent-messages {
    flex: 1 1 0;
    min-height: 0;
    overflow: auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    font-size: 0.9rem;
}
.write-agent-messages .agent-msg {
    padding: 0.55rem 0.75rem;
    background: var(--bg1);
    border-radius: var(--br);
    border: 1px solid var(--border);
    line-height: 1.5;
    max-width: 88%;
    align-self: flex-start;
}
.write-agent-messages .agent-msg.user {
    background: var(--pastel-3);
    align-self: flex-end;
    border-radius: var(--br) var(--br) 4px var(--br);
}
.write-agent-messages .agent-msg.bot {
    border-radius: var(--br) var(--br) var(--br) 4px;
}
.write-agent-messages .agent-msg a {
    color: var(--accent, #5b8def);
    text-decoration: underline;
    text-decoration-color: rgba(91, 141, 239, 0.3);
}
.write-agent-messages .agent-msg a:hover {
    text-decoration-color: var(--accent, #5b8def);
}
.write-agent-messages .agent-msg :first-child {
    margin-top: 0;
}
.write-agent-messages .agent-msg :last-child {
    margin-bottom: 0;
}
.write-agent-messages .agent-msg p {
    margin: 0.4rem 0;
}
.write-agent-messages .agent-msg pre {
    padding: 0.5rem 0.65rem;
    background: var(--bg2);
    border-radius: var(--br);
    overflow-x: auto;
    font-size: 0.82rem;
}
.write-agent-messages .agent-msg code {
    padding: 0.1rem 0.25rem;
    background: var(--bg2);
    border-radius: 4px;
    font-size: 0.84rem;
}
.write-agent-messages .agent-msg blockquote {
    margin: 0.4rem 0;
    padding: 0.4rem 0.7rem;
    border-left: 3px solid var(--bg3);
    color: var(--c2);
}
.write-agent-messages .agent-msg ul,
.write-agent-messages .agent-msg ol {
    margin: 0.4rem 0;
    padding-left: 1.25rem;
}
.write-agent-messages .agent-msg h1,
.write-agent-messages .agent-msg h2,
.write-agent-messages .agent-msg h3,
.write-agent-messages .agent-msg h4,
.write-agent-messages .agent-msg h5,
.write-agent-messages .agent-msg h6 {
    font-size: 0.95rem;
    font-weight: 600;
    margin: 0.6rem 0 0.25rem;
    padding-bottom: 0.15rem;
    border-bottom: 1px solid var(--border);
    color: var(--c1);
}
.write-agent-messages .agent-msg h1 {
    font-size: 1rem;
}
.write-agent-messages .agent-msg h2 {
    font-size: 0.95rem;
}
.write-agent-messages .agent-msg h3 {
    font-size: 0.9rem;
    font-style: italic;
    border-bottom: none;
}
.write-agent-messages .agent-msg h4,
.write-agent-messages .agent-msg h5,
.write-agent-messages .agent-msg h6 {
    font-size: 0.88rem;
    font-style: italic;
    border-bottom: none;
}
.write-agent-activity {
    flex: 1;
    min-height: 0;
    overflow: auto;
    font-size: 0.82rem;
}
.write-agent-activity[hidden] {
    display: none !important;
}
.write-agent-messages .agent-msg.note {
    background: transparent;
    border: 1px dashed var(--border);
    color: var(--c2);
    font-size: 0.78rem;
    padding: 0.35rem 0.6rem;
}
.write-agent-history {
    flex: 1 1 0;
    min-height: 0;
    overflow: auto;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}
.write-agent-history[hidden] {
    display: none !important;
}
.write-agent-history-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
}
.write-agent-history-head .dsg-btn {
    padding: 0.28rem 0.6rem;
    font-size: 0.76rem;
}
.write-agent-history-item {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    text-align: left;
    width: 100%;
    padding: 0.5rem 0.6rem;
    background: var(--bg1);
    border: 1px solid var(--border);
    border-radius: var(--br);
    cursor: pointer;
    color: var(--c1);
}
.write-agent-history-item:hover {
    border-color: var(--bg3);
}
.write-agent-history-title {
    font-size: 0.84rem;
    font-weight: 600;
}
.write-agent-history-meta {
    font-size: 0.72rem;
    color: var(--c2);
}
.write-agent-event {
    margin-bottom: 0.5rem;
    padding: 0.5rem;
    border-left: 3px solid var(--bg3);
    background: var(--bg1);
    border-radius: var(--br);
}
.write-agent-event strong {
    display: block;
    color: var(--c1);
}
.write-agent-event span {
    color: var(--c2);
}
.write-agent-event pre {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    margin: 0.35rem 0 0;
    color: var(--c2);
}

.write-agent-form {
    flex: 0 0 auto;
    display: flex;
    flex-direction: row;
    align-items: flex-end;
    gap: 0.45rem;
    padding: 0;
    margin-bottom: 0.35rem;
    background: transparent;
    box-shadow: none;
}
.write-agent-form textarea {
    flex: 1;
    min-height: 4.2rem;
    max-height: 12rem;
    padding: 0.55rem 0.7rem;
    font-size: 0.9rem;
    resize: none;
    overflow-y: auto;
}
.write-agent-form button[type="submit"] {
    flex: 0 0 auto;
    width: auto;
    min-width: 0;
    padding: 0.55rem 0.9rem;
    border-radius: 999px;
    font-size: 0.86rem;
    box-shadow: none;
}

.write-agent-staged {
    flex: 0 0 auto;
    display: flex;
    justify-content: flex-end;
    gap: 0.45rem;
}
.write-agent-staged[hidden] {
    display: none !important;
}
.write-agent-staged .dsg-btn {
    width: auto;
    min-width: 0;
    padding: 0.32rem 0.7rem;
    border-radius: 999px;
    font-size: 0.8rem;
    box-shadow: none;
}
.write-presence[hidden] {
    display: none !important;
}
.write-version-item {
    width: 100%;
    margin-bottom: 0.5rem;
    text-align: left;
}
.write-version-preview {
    min-height: 12rem;
    overflow: auto;
    white-space: pre-wrap;
    margin: 0.75rem 0;
}
#versions-revert {
    width: 100%;
}
.write-options-card {
    max-width: 720px;
}
.write-option-row {
    display: grid;
    grid-template-columns: 1fr minmax(12rem, 16rem);
    gap: 1rem;
    align-items: center;
}
.write-option-row p {
    margin: 0.25rem 0 0;
}
.write-recovery-item {
    margin-bottom: 0.75rem;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--br);
    background: var(--bg1);
}
.write-comments-header {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}
.write-panel-close {
    width: 2rem !important;
    height: 2rem;
    padding: 0 !important;
    border-radius: 999px;
    font-size: 1.1rem !important;
    line-height: 1;
}
.write-comments-all {
    width: 100%;
    margin-bottom: 0.75rem;
}
.write-comments-search {
    margin-bottom: 0.55rem;
    padding: 0.55rem 0.7rem;
    font-size: 0.9rem;
}
.write-comment-link strong,
.write-comment-link {
    overflow-wrap: anywhere;
}
.write-comment-detail {
    width: 100%;
    max-width: 64rem;
    box-sizing: border-box;
    margin: 0 auto;
}
.write-comment-detail .dsg-card-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0.55rem;
}
.write-comment-detail .write-toolbar {
    justify-self: end;
    margin-top: 0;
}
.write-comment-detail-body {
    gap: 0.75rem;
}
.write-comment-detail blockquote {
    margin: 0;
    padding: 0.85rem 1rem;
    border-left: 3px solid rgba(232, 196, 96, 0.65);
    border-radius: var(--br);
    background: var(--bg1);
    color: var(--c1);
    font-size: 1.05rem;
    line-height: 1.55;
}
.write-comment-detail #comment-body {
    min-height: min(34vh, 18rem);
    line-height: 1.55;
    resize: vertical;
}
.write-comment-item {
    margin-bottom: 0.75rem;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--br);
    background: var(--bg1);
}
.write-comment-item.active {
    border-color: rgba(232, 196, 96, 0.55);
    box-shadow: 0 0 0 2px rgba(232, 196, 96, 0.12);
}
.write-comment-item blockquote {
    margin: 0.5rem 0;
    padding-left: 0.5rem;
    border-left: 2px solid var(--bg3);
    color: var(--c1);
}
.write-comment-item p {
    margin: 0.5rem 0;
    color: var(--c1);
}
.write-comment-actions {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}
.write-note-item {
    margin-bottom: 0.75rem;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-left: 3px solid var(--note-color, #3d6df2);
    border-radius: var(--br);
    background: var(--bg1);
}
.write-note-item .dsg-input {
    margin-bottom: 0.5rem;
}
.write-notes-search {
    margin-bottom: 0.55rem;
    padding: 0.55rem 0.7rem;
    font-size: 0.9rem;
}
.write-note-link {
    position: relative;
    padding-left: 0.85rem;
    border-left: 3px solid var(--note-color, #3d6df2);
}
.write-note-link strong {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.write-note-link.drag-over {
    outline: 2px solid var(--note-color, #3d6df2);
    outline-offset: 2px;
}
.write-note-editor {
    width: 100%;
    max-width: 72rem;
    height: calc(100vh - 7rem);
    max-height: calc(100vh - 7rem);
    box-sizing: border-box;
    margin: 0 auto;
    border-top: 3px solid var(--note-color, #3d6df2);
    grid-template-rows: auto minmax(0, 1fr);
    overflow: hidden;
}
.write-note-editor .dsg-card-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0.55rem;
}
.write-note-editor .write-toolbar {
    justify-self: end;
    margin-top: 0;
}
.write-note-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto auto auto auto minmax(0, 1fr);
    gap: 0.55rem;
    min-height: 0;
    overflow: hidden;
}
.write-note-form #note-title {
    font-size: clamp(1.1rem, 2vw, 1.45rem);
    font-weight: 700;
}
.write-note-form #note-body {
    height: 100%;
    min-height: 0;
    resize: none;
    overflow: auto;
    line-height: 1.55;
}
.write-note-colors {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}
.write-note-colors input[type="color"] {
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--br);
    background: var(--bg1);
}
.write-note-colors .write-timeline-color.active {
    outline: 2px solid var(--c1);
    outline-offset: 2px;
}
.write-codex-category summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}
.write-codex-category summary .dsg-btn {
    padding: 0.2rem 0.45rem;
    width: auto;
    min-width: 0;
}
.write-codex-search {
    margin-bottom: 0.55rem;
    padding: 0.55rem 0.7rem;
    font-size: 0.9rem;
}
.write-codex-dashboard-search {
    max-width: 34rem;
    padding: 0.65rem 0.8rem;
    font-size: 0.95rem;
}
.write-codex-link {
    border-left: 3px solid var(--codex-color, #3d6df2);
    padding-left: 0.65rem;
    cursor: grab;
}
.write-codex-link.drag-over {
    background: var(--pastel-1);
}
.write-codex-home {
    display: grid;
    gap: 1rem;
    width: 100%;
    max-width: none;
}
.write-codex-home > header {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 1rem;
}
.write-codex-home h2,
.write-codex-home h3 {
    margin: 0;
}
.write-codex-home-category {
    display: grid;
    gap: 0.55rem;
    padding: 0.8rem;
    border: 1px solid var(--border);
    border-radius: var(--br);
    background: rgba(255, 255, 255, 0.015);
}
.write-codex-home-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}
.write-codex-home-header .dsg-btn {
    width: auto;
    min-width: 0;
    max-width: none;
    padding: 0.32rem 0.58rem;
    border-radius: 999px;
    font-size: 0.82rem;
    box-shadow: none;
}
.write-codex-entry-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
    gap: 0.45rem;
}
.write-codex-entry-card {
    display: block;
    padding: 0.55rem 0.65rem;
    border: 1px solid var(--border);
    border-left: 3px solid var(--codex-color, #3d6df2);
    border-radius: var(--br);
    background: var(--bg1);
    color: var(--c1);
    text-decoration: none;
    min-width: 0;
    cursor: grab;
}
.write-codex-entry-card:hover {
    background: var(--pastel-1);
    border-color: rgba(77, 107, 92, 0.55);
}
.write-codex-entry-card.drag-over {
    background: var(--pastel-1);
    border-color: var(--codex-color, #3d6df2);
}
.write-codex-entry-card strong {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.write-codex-card {
    width: 100%;
    max-width: none;
}
.write-codex-form {
    display: grid;
    gap: 0.9rem;
    width: 100%;
    max-width: none;
    padding: 1rem;
    background: transparent;
    box-shadow: none;
}
.write-codex-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.45rem;
    flex-wrap: wrap;
}
.write-codex-actions .dsg-btn,
.write-codex-add-row .dsg-btn {
    width: auto;
    min-width: 0;
    max-width: none;
    padding: 0.38rem 0.7rem;
    border-radius: 999px;
    font-size: 0.86rem;
    box-shadow: none;
}
.write-codex-add-row {
    display: flex;
    justify-content: flex-start;
}
.write-codex-colors {
    margin-top: 0.1rem;
}
.write-codex-field {
    display: grid;
    gap: 0.35rem;
    align-items: start;
    margin: 0;
    cursor: default;
}
.write-codex-label {
    color: var(--c1);
    font-weight: 700;
    line-height: 1.35;
}
.write-codex-form .dsg-input {
    color: var(--c1);
    background: var(--input-bg);
    line-height: 1.5;
}
.write-codex-form textarea.dsg-input {
    min-height: 8rem;
    resize: vertical;
}
.write-codex-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0.75rem;
    margin-bottom: 1rem;
}
.write-codex-section {
    display: grid;
    gap: 0.75rem;
    margin-top: 0.25rem;
    padding: 0.85rem;
    border: 1px solid var(--border);
    border-radius: var(--br);
    background: rgba(255, 255, 255, 0.015);
}
.write-codex-section h3 {
    margin: 0;
    font-size: 1rem;
    color: var(--c1);
}
.write-codex-questions {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0.85rem;
}
.write-codex-question .write-codex-label {
    font-weight: 650;
}
.write-codex-custom {
    display: grid;
    grid-template-columns: minmax(160px, 260px) 1fr;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}
.write-template-card {
    width: min(58rem, 96vw);
    max-width: none !important;
}
.write-template-picker {
    display: block;
    width: 100%;
    max-height: min(76vh, 46rem);
    overflow: auto;
    padding: 0.55rem !important;
}
.write-template-choice {
    display: block;
    text-align: left;
    width: 100%;
    max-width: none;
    min-height: 2.75rem;
    height: auto;
    padding: 0.42rem 0.55rem;
    border: 0;
    border-radius: var(--br);
    box-shadow: none;
    background: transparent;
    color: var(--c1);
    overflow: visible;
    cursor: pointer;
}
.write-template-choice + .write-template-choice {
    margin-top: 0.18rem;
}
.write-template-choice:hover {
    background: var(--pastel-1);
    transform: none;
    box-shadow: none;
}
.write-template-choice strong {
    line-height: 1.18;
    font-size: 0.98rem;
}
.write-template-choice span {
    display: block;
    color: var(--c2);
    font-size: 0.82rem;
    line-height: 1.25;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
}
.write-timeline {
    height: calc(100vh - 5.15rem);
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}
.write-timeline-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    min-height: 2.25rem;
}
.write-timeline-toolbar h2 {
    margin: 0;
    font-size: clamp(1.15rem, 1.9vw, 1.65rem);
    line-height: 1.1;
}
.write-timeline-toolbar-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.3rem;
    flex-wrap: wrap;
}
.write-timeline-toolbar .dsg-btn {
    width: auto;
    min-width: 0;
    max-width: none;
    padding: 0.34rem 0.58rem;
    border-radius: 999px;
    font-size: 0.82rem;
    box-shadow: none;
}
.write-timeline-zoom {
    display: inline-block;
    min-width: 2.7rem;
    text-align: center;
    color: var(--c2);
    font-size: 0.82rem;
}
.write-timeline-scroll {
    flex: 1;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: var(--br);
    background: var(--bg2);
    cursor: grab;
}
.write-timeline-grid {
    display: grid;
    grid-template-columns: var(--timeline-row-header-width, 132px) repeat(
            var(--timeline-columns, 12),
            var(--timeline-cell-width, 180px)
        );
    align-items: stretch;
    min-width: max-content;
}
.write-timeline-corner,
.write-timeline-col-head,
.write-timeline-row-head,
.write-timeline-empty-axis {
    position: sticky;
    z-index: 2;
    background: var(--bg1);
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    padding: 0.34rem;
}
.write-timeline-corner {
    top: 0;
    left: 0;
    z-index: 4;
    color: var(--c2);
    font-size: 0.72rem;
}
.write-timeline-row-resize {
    position: absolute;
    top: 0;
    right: -5px;
    bottom: 0;
    width: 10px;
    cursor: col-resize;
    z-index: 6;
}
.write-timeline-row-resize::after {
    content: "";
    position: absolute;
    top: 0;
    right: 4px;
    bottom: 0;
    width: 1px;
    background: rgba(255, 255, 255, 0.18);
}
.write-timeline-row-resize:hover::after,
.write-timeline-row-resize:active::after {
    width: 2px;
    background: var(--bg3);
}
.write-resizing-timeline-row,
.write-resizing-timeline-row * {
    cursor: col-resize !important;
    user-select: none;
}
.write-timeline-col-head,
.write-timeline-empty-axis {
    top: 0;
    min-height: 3.65rem;
}
.write-timeline-row-head {
    left: 0;
    z-index: 3;
    min-height: 5.2rem;
    display: grid;
    grid-template-columns: 1.65rem minmax(0, 1fr);
    gap: 0.25rem;
    align-content: start;
}
.write-timeline-row-head .dsg-input,
.write-timeline-col-head .dsg-input {
    margin-bottom: 0.25rem;
    padding: 0.42rem 0.5rem;
    min-height: 0;
    color: var(--c1);
    font-size: 0.82rem;
    background: var(--input-bg);
}
.write-timeline-row-head .write-drag-handle {
    width: 1.55rem;
    height: 1.55rem;
    padding: 0;
    border-radius: var(--br);
    font-size: 0.76rem;
}
.write-timeline-row-head .write-drag-handle + .dsg-input {
    min-width: 0;
}
.write-timeline-axis-actions {
    grid-column: 1 / -1;
    display: flex;
    gap: 0.18rem;
    flex-wrap: wrap;
}
.write-timeline-axis-actions .dsg-btn {
    width: auto;
    min-width: 0;
    max-width: none;
    padding: 0.18rem 0.32rem;
    border-radius: 999px;
    font-size: 0.68rem;
    box-shadow: none;
}
.write-timeline-cell {
    min-height: 5.2rem;
    padding: 0.32rem;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.015);
}
.write-timeline-item {
    display: block;
    width: 100%;
    margin-bottom: 0.25rem;
    padding: 0.34rem 0.42rem;
    text-align: left;
    border: 1px solid var(--timeline-item-color, rgba(77, 107, 92, 0.5));
    border-left: 0.28rem solid var(--timeline-item-color, var(--bg3));
    border-radius: var(--br);
    background: color-mix(
        in srgb,
        var(--timeline-item-color, var(--bg3)) 18%,
        var(--bg1)
    );
    color: var(--c1);
    cursor: grab;
    font-size: 0.8rem;
    line-height: 1.2;
}
.write-timeline-item small {
    display: block;
    margin-top: 0.2rem;
    color: var(--c2);
}
.write-timeline-add-item {
    width: 100%;
    max-width: none;
    margin-top: 0.12rem;
    padding: 0.24rem 0.35rem;
    min-height: 0;
    border-radius: var(--br);
    font-size: 0.75rem;
    box-shadow: none;
    opacity: 0.72;
}
.write-timeline-add-item:hover {
    opacity: 1;
}
.write-timeline-hidden {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--br);
    background: var(--bg1);
}
.write-timeline-hidden .dsg-btn {
    width: auto;
    margin: 0.4rem 0.4rem 0 0;
}
.write-timeline-dialog {
    width: min(42rem, 92vw);
}
.write-timeline-colors {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}
.write-timeline-colors input[type="color"] {
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--br);
    background: var(--bg1);
}
.write-timeline-color {
    width: 1.7rem;
    height: 1.7rem;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--timeline-item-color);
    cursor: pointer;
}
.write-comment-token {
    position: absolute;
    z-index: 20;
    width: 1.35rem;
    height: 1.35rem;
    padding: 0;
    border: 1px solid rgba(232, 196, 96, 0.45);
    border-radius: 999px;
    background: var(--bg1);
    color: #e8c460;
    font-size: 0.85rem;
    line-height: 1;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
}
.write-editor-focus .write-comment-token {
    z-index: 8001;
}
::highlight(write-annotations) {
    background: rgba(232, 196, 96, 0.28);
}
::highlight(write-active-annotation) {
    background: rgba(232, 196, 96, 0.55);
}

.write-home {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}
.write-home-card {
    width: 100%;
    max-width: 28rem;
}
.write-home-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}
.write-home-actions .dsg-btn,
.write-auth-form .dsg-btn,
.dsg-card-body > .dsg-btn {
    width: auto;
    max-width: none;
}
.write-projects-home {
    width: min(1180px, 100%);
    margin: 0 auto;
    padding: clamp(1rem, 3vw, 2rem);
    display: grid;
    gap: 1.1rem;
}
.write-projects-header {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 1rem;
}
.write-projects-header-side {
    display: grid;
    justify-items: end;
    gap: 0.75rem;
}
.write-projects-header h1 {
    margin: 0;
    font-size: clamp(1.8rem, 4vw, 3rem);
}
.write-projects-header p {
    margin: 0.25rem 0 0;
}
.write-project-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
    gap: 0.8rem;
}
.write-project-card {
    display: grid;
    gap: 0.65rem;
    padding: 0.9rem;
    border: 1px solid var(--border);
    border-top: 3px solid var(--project-color, #3d6df2);
    border-radius: var(--br);
    background: var(--bg2);
    box-shadow: var(--shadow-sm);
    cursor: grab;
    min-width: 0;
}
.write-project-card.drag-over {
    outline: 2px solid var(--project-color, #3d6df2);
    outline-offset: 2px;
}
.write-project-card-top,
.write-project-card-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}
.write-project-dot {
    width: 0.85rem;
    height: 0.85rem;
    border-radius: 999px;
    background: var(--project-color, #3d6df2);
    box-shadow: 0 0 0 3px
        color-mix(in srgb, var(--project-color, #3d6df2) 22%, transparent);
}
.write-project-theme {
    color: var(--c2);
    font-size: 0.78rem;
}
.write-project-card h2 {
    margin: 0;
    font-size: clamp(1.1rem, 2vw, 1.35rem);
}
.write-project-logline {
    min-height: 3.4rem;
    margin: 0;
    color: var(--c1);
    line-height: 1.45;
}
.write-project-meta {
    display: grid;
    gap: 0.25rem;
    color: var(--c2);
    font-size: 0.82rem;
}
.write-project-meta span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.write-project-card-actions .dsg-btn {
    width: auto;
    min-width: 0;
    max-width: none;
    padding: 0.42rem 0.7rem;
    border-radius: 999px;
    font-size: 0.86rem;
    box-shadow: none;
}
.write-project-dialog {
    width: min(760px, 94vw);
    max-width: none !important;
    max-height: 92vh;
    grid-template-rows: auto minmax(0, 1fr) auto;
}
.write-project-dialog .dsg-card-body {
    overflow: auto;
}
.write-project-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
}
.write-project-field {
    display: grid;
    gap: 0.35rem;
    margin: 0;
    align-items: start;
    cursor: default;
    color: var(--c1);
    font-weight: 700;
}
.write-project-field-wide {
    grid-column: 1 / -1;
}
.write-project-field textarea {
    resize: vertical;
    line-height: 1.5;
}
.write-project-colors {
    margin-top: 0.1rem;
}

.write-auth {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}
.write-auth-title {
    text-align: center;
    margin-bottom: 1.5rem;
}
.write-auth-card {
    width: 100%;
    max-width: 400px;
}
.write-auth-form {
    padding: 0;
    background: transparent;
    box-shadow: none;
}
.write-auth-links {
    text-align: center;
    margin-top: 1rem;
}
.write-hint {
    font-size: 0.9em;
    color: var(--c2);
    margin: -0.25rem 0 0.5rem;
}
.write-flash {
    margin-bottom: 1rem;
    padding: 1rem;
}
.write-flash-ok {
    background: linear-gradient(135deg, var(--pastel-4), var(--pastel-4));
    color: var(--c1);
}
.write-flash-err {
    background: linear-gradient(135deg, var(--pastel-3), var(--pastel-3));
    color: var(--c1);
}

[data-theme="ink"] .write-agent-messages .agent-msg {
    background: var(--pastel-1);
    border: 1px solid var(--border);
}
[data-theme="ink"] .write-agent-messages .agent-msg.user {
    background: var(--pastel-3);
}

[data-theme="ink"] .write-chapter-header h2 {
    color: var(--c1);
    font-weight: 600;
}

#toast-editor .toastui-editor-defaultUI {
    border-color: var(--border);
    border-radius: var(--br);
}
#toast-editor .toastui-editor-defaultUI-toolbar {
    background: var(--bg2);
    border-color: var(--border);
}
#toast-editor .toastui-editor-defaultUI-toolbar {
    overflow-x: auto;
    overflow-y: hidden;
}

.write-editor-focus .write-nav,
.write-editor-focus .write-sidebar,
.write-editor-focus .write-chapter-header,
.write-editor-focus .write-status,
.write-editor-focus .write-agent-panel {
    display: none !important;
}
.write-editor-focus .write-layout {
    display: block;
    min-height: 100vh;
}
.write-editor-focus .write-main {
    padding: 0;
    overflow: hidden;
}
.write-editor-focus #toast-editor {
    position: fixed;
    inset: 0;
    z-index: 8000;
    background: var(--bg1);
}
.write-editor-focus .dsg-dialog[open] {
    z-index: 12000;
}
.write-editor-focus #toast-editor .toastui-editor-defaultUI {
    height: 100vh !important;
    border: 0;
    border-radius: 0;
}

@media (max-width: 1024px) {
    .write-layout {
        display: block;
        height: calc(100vh - 36px);
        max-height: calc(100vh - 36px);
        overflow: hidden;
    }
    .write-agent-pinned .write-layout {
        grid-template-columns: 1fr;
    }
    .write-sidebar {
        display: block;
        position: fixed;
        top: 3rem;
        left: 0;
        bottom: 0;
        height: auto;
        width: min(21rem, 88vw);
        max-height: none;
        z-index: 9998;
        border-right: 1px solid var(--border);
        border-bottom: 0;
        background: var(--bg2);
        box-shadow: var(--shadow-lg);
        transform: translateX(0);
        transition: transform 0.24s ease;
    }
    .write-sidebar-resize {
        display: none;
    }
    .write-sidebar-collapsed .write-sidebar {
        display: block;
        transform: translateX(-105%);
    }
    .write-no-sidebar .write-sidebar {
        display: none !important;
    }
    .write-main {
        padding: 0.75rem;
    }
    .write-agent-panel:not(.active) {
        display: none;
    }
    .write-agent-panel.pinned {
        position: fixed;
        inset: 0 0 0 auto;
        width: min(var(--write-agent-width, 380px), 92vw);
        height: 100vh;
    }
    .write-codex-grid,
    .write-codex-questions {
        grid-template-columns: 1fr;
    }
    .write-codex-custom {
        grid-template-columns: 1fr;
    }
    .write-option-row {
        grid-template-columns: 1fr;
    }
    .write-projects-header {
        align-items: start;
        flex-direction: column;
    }
    .write-projects-header-side {
        justify-items: start;
        width: 100%;
    }
    .write-profile-picker-compact {
        width: min(100%, 28rem);
    }
    .write-project-form {
        grid-template-columns: 1fr;
    }
    .write-note-editor {
        height: calc(100vh - 7rem);
        max-height: calc(100vh - 7rem);
    }
    .write-chapter-header {
        align-items: flex-start;
        flex-direction: column;
    }
    .write-binder-title {
        white-space: normal;
        overflow-wrap: anywhere;
    }
    .write-row-actions {
        grid-column: 1 / -1;
        padding-left: 2.4rem;
    }
    .write-order-btn {
        display: inline-flex;
    }
    .write-act-block {
        padding: 0.4rem 0;
    }
}

@media (max-width: 560px) {
    .write-sidebar-header {
        grid-template-columns: 1fr;
        align-items: start;
    }
    .write-sidebar-header-actions {
        justify-content: flex-start;
        flex-wrap: wrap;
    }
    .write-projects-home {
        padding: 0.6rem;
    }
    .write-project-card-actions {
        align-items: stretch;
        flex-direction: column;
    }
    .write-project-card-actions .dsg-btn {
        width: 100%;
    }
}

@media (min-width: 1025px) {
    .write-menu-toggle {
        display: none;
    }
}
