
    :root {
      --bg: #0b1020;
      --bg-alt: #141a30;
      --panel: #181f3a;
      --accent: #ffb347;
      --accent-soft: rgba(255, 179, 71, 0.1);
      --text: #f7f7ff;
      --muted: #9ca3c7;
      --border: #272f55;
      --danger: #ff5c7a;
      --radius: 10px;
      --shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
      --font-main: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
      --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    }

    * {
      box-sizing: border-box;
    }

    html, body {
      margin: 0;
      padding: 0;
      height: 100%;
      overflow-y: hidden;
      font-family: var(--font-main);
      background: radial-gradient(circle at top, #20294b 0, var(--bg) 45%, #050713 100%);
      color: var(--text);
    }

    body {
      display: flex;
      flex-direction: column;
    }

    header {
      padding: 1rem 1.5rem;
      border-bottom: 1px solid var(--border);
      background: linear-gradient(90deg, rgba(24, 31, 58, 0.98), rgba(11, 16, 32, 0.98));
      backdrop-filter: blur(12px);
      position: sticky;
      top: 0;
      z-index: 20;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 1.5rem;
    }

    header h1 {
      margin: 0;
      font-size: 1.25rem;
      letter-spacing: 0.04em;
      text-transform: uppercase;
    }

    header h1 span {
      font-weight: 300;
      color: var(--muted);
      font-size: 0.9rem;
    }

    .header-actions {
      display: flex;
      gap: 0.75rem;
      align-items: center;
      flex-wrap: wrap;
      justify-content: flex-end;
    }

    .btn {
      border-radius: 999px;
      border: 1px solid var(--border);
      background: rgba(10, 15, 35, 0.9);
      color: var(--text);
      padding: 0.4rem 0.9rem;
      font-size: 0.8rem;
      display: inline-flex;
      align-items: center;
      gap: 0.35rem;
      cursor: pointer;
      transition: background 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
      white-space: nowrap;
    }

    .btn.primary {
      background: linear-gradient(145deg, #ffb347, #ff7e5f);
      border-color: transparent;
      color: #1b1020;
      font-weight: 600;
    }

    .btn.danger {
      border-color: rgba(255, 92, 122, 0.5);
      color: #ffdbe4;
    }

    .btn.small {
      padding: 0.25rem 0.6rem;
      font-size: 0.75rem;
    }

    .btn:hover {
      background: rgba(25, 34, 70, 0.95);
      border-color: var(--accent);
      transform: translateY(-1px);
    }

    .btn.primary:hover {
      background: linear-gradient(145deg, #ffd06f, #ff916f);
    }

    .btn.danger:hover {
      background: rgba(255, 92, 122, 0.15);
    }

    .btn:active {
      transform: translateY(0);
    }

    .icon {
      font-family: var(--font-mono);
      font-size: 0.85em;
      opacity: 0.8;
    }

    main {
      display: flex;
      flex: 1;
      min-height: 0;
      overflow: hidden;
    }

    .sidebar {
      width: 260px;
      max-width: 40vw;
      border-right: 1px solid var(--border);
      background: radial-gradient(circle at top left, rgba(255, 179, 71, 0.1), transparent 55%),
                  linear-gradient(to bottom, rgba(11, 16, 32, 0.98), rgba(5, 7, 19, 0.98));
      padding: 0.9rem 0.8rem 0.8rem;
      display: flex;
      flex-direction: column;
      gap: 0.75rem;
      overflow-y: auto;
    }

    .project-select {
      border-radius: 999px;
      border: 1px solid var(--border);
      background: rgba(5, 7, 19, 0.9);
      color: var(--text);
      font-size: 0.8rem;
      padding: 0.35rem 0.7rem;
      max-width: 220px;
    }

    .project-title-input {
      width: 100%;
      padding: 0.45rem 0.6rem;
      border-radius: 999px;
      border: 1px solid var(--border);
      background: rgba(5, 7, 19, 0.9);
      color: var(--text);
      font-size: 0.85rem;
    }

    .project-title-input::placeholder {
      color: var(--muted);
    }

    .nav-section-label {
      font-size: 0.7rem;
      text-transform: uppercase;
      letter-spacing: 0.13em;
      color: var(--muted);
      margin: 0.2rem 0 0.3rem;
      padding: 0 0.3rem;
    }

    .nav-list {
      list-style: none;
      margin: 0;
      padding: 0;
      display: flex;
      flex-direction: column;
      gap: 0.2rem;
    }

    .nav-item {
      border-radius: 999px;
      padding: 0.35rem 0.55rem;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 0.3rem;
      font-size: 0.8rem;
      cursor: pointer;
      color: var(--muted);
      border: 1px solid transparent;
    }

    .nav-item-right {
      display: inline-flex;
      align-items: center;
      gap: 0.25rem;
      margin-left: auto;
    }

    .nav-item span {
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .nav-item.active {
      background: rgba(255, 179, 71, 0.12);
      border-color: rgba(255, 179, 71, 0.5);
      color: var(--text);
    }

    .nav-item:hover {
      background: rgba(39, 47, 85, 0.9);
      color: var(--text);
    }

    .nav-count {
      font-size: 0.7rem;
      padding: 0.08rem 0.38rem;
      border-radius: 999px;
      background: rgba(3, 6, 23, 0.7);
      border: 1px solid var(--border);
      color: var(--muted);
    }

    .sidebar-footer {
      margin-top: auto;
      padding-top: 0.6rem;
      border-top: 1px dashed rgba(76, 86, 128, 0.6);
      display: flex;
      flex-direction: column;
      gap: 0.35rem;
      font-size: 0.7rem;
      color: var(--muted);
    }

    .sidebar-footer span {
      opacity: 0.85;
    }

    .content {
      flex: 1;
      display: flex;
      flex-direction: column;
      min-width: 0;
      max-width: 100%;
    }

    .section-tabs {
      display: none;
    }

    .tab {
      padding: 0.25rem 0.75rem;
      border-radius: 999px;
      border: 1px solid transparent;
      font-size: 0.8rem;
      color: var(--muted);
      cursor: pointer;
      white-space: nowrap;
      display: inline-flex;
      align-items: center;
      gap: 0.35rem;
    }

    .tab.active {
      background: var(--accent-soft);
      border-color: rgba(255, 179, 71, 0.7);
      color: var(--text);
    }

    .tab-count {
      font-size: 0.7rem;
      padding: 0.05rem 0.35rem;
      border-radius: 999px;
      background: rgba(3, 6, 23, 0.7);
      border: 1px solid var(--border);
      color: var(--muted);
    }

    .section-container {
      flex: 1;
      display: flex;
      flex-direction: column;
      min-height: 0;
      padding: 0.8rem 1rem 1rem;
      gap: 0.7rem;
      overflow: hidden;
    }

    .section-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      flex-wrap: wrap;
      gap: 0.5rem;
    }

    .section-title {
      margin: 0;
      font-size: 1rem;
      letter-spacing: 0.12em;
      text-transform: uppercase;
      color: var(--muted);
    }

    .section-description {
      margin: 0.15rem 0 0;
      font-size: 0.75rem;
      color: var(--muted);
      max-width: 600px;
    }

    .section-header-left {
      display: flex;
      flex-direction: column;
    }

    .entries-toolbar {
      display: flex;
      gap: 0.4rem;
      flex-wrap: wrap;
      align-items: center;
    }

    .entries-toolbar select, .entries-toolbar input[type="search"] {
      border-radius: 999px;
      border: 1px solid var(--border);
      background: rgba(5, 7, 19, 0.95);
      color: var(--text);
      font-size: 0.8rem;
      padding: 0.25rem 0.55rem;
    }

    .entries-toolbar input[type="search"]::placeholder {
      color: var(--muted);
    }

    .entries {
      flex: 1;
      min-height: 0;
      display: flex;
      flex-direction: column;
      align-items: stretch;
      gap: 0.5rem;
      padding-top: 0.2rem;
      overflow-y: auto;
      align-content: flex-start;
    }

    .entry-card {
      flex: 0 0 auto;
      background: radial-gradient(circle at top left, rgba(255, 179, 71, 0.06), transparent 55%),
                  linear-gradient(to bottom right, rgba(17, 24, 39, 0.98), rgba(12, 15, 32, 0.98));
      border-radius: var(--radius);
      border: 1px solid rgba(55, 65, 106, 0.9);
      box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
      padding: 0.65rem 0.7rem 0.6rem;
      display: flex;
      flex-direction: column;
      gap: 0.3rem;
      position: relative;
    }

    .entry-card.drag-over {
      border-color: rgba(255, 179, 71, 0.8);
      background: radial-gradient(circle at top left, rgba(255, 179, 71, 0.15), transparent 55%),
                  linear-gradient(to bottom right, rgba(24, 32, 60, 0.98), rgba(12, 18, 40, 0.98));
    }

    .entry-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 0.4rem;
    }

    .entry-header-left {
      display: inline-flex;
      align-items: center;
      gap: 0.35rem;
      flex: 1;
      min-width: 0;
    }

    .entry-card.collapsed {
      padding-top: 0.45rem;
      padding-bottom: 0.45rem;
    }

    .entry-card.collapsed .entry-body,
    .entry-card.collapsed .entry-footer {
      display: none;
    }

    .entry-collapse-btn {
      border-radius: 999px;
      border: 1px solid rgba(55, 65, 106, 0.9);
      background: rgba(10, 15, 35, 0.9);
      color: var(--muted);
      cursor: pointer;
      font-size: 0.7rem;
      padding: 0.1rem 0.35rem;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      min-width: 1.4rem;
    }

    .entry-collapse-btn:hover {
      background: rgba(39, 47, 85, 0.9);
      color: var(--text);
    }

    .entry-title-input {
      width: 100%;
      border: none;
      outline: none;
      background: transparent;
      color: var(--text);
      font-size: 0.95rem;
      font-weight: 600;
    }

    .entry-meta {
      display: flex;
      flex-wrap: wrap;
      gap: 0.25rem;
      font-size: 0.7rem;
      color: var(--muted);
      align-items: center;
    }

    .location-parent-select {
      max-width: 220px;
      padding: 0.1rem 0.35rem;
      border-radius: 999px;
      border: 1px solid rgba(55, 65, 106, 0.9);
      background: rgba(15, 23, 42, 0.95);
      color: var(--text);
      font-size: 0.7rem;
    }

    .badge {
      padding: 0.05rem 0.4rem;
      border-radius: 999px;
      background: rgba(12, 18, 40, 0.9);
      border: 1px solid rgba(55, 65, 106, 0.9);
    }

    .badge.label {
      text-transform: uppercase;
      letter-spacing: 0.08em;
      font-size: 0.65rem;
    }

    .entry-body {
      display: flex;
      flex-direction: column;
      gap: 0.3rem;
      margin-top: 0.15rem;
    }

    .entry-image-wrapper {
      display: flex;
      flex-direction: column;
      gap: 0.4rem;
      margin-top: 0.2rem;
    }

    .entry-image-gallery {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
      gap: 0.4rem;
    }

    .entry-image-item {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 0.2rem;
    }

    .entry-image-preview {
      width: 80px;
      height: 80px;
      border-radius: 8px;
      object-fit: cover;
      border: 1px solid rgba(55, 65, 106, 0.9);
      background: rgba(15, 23, 42, 0.9);
    }

    .entry-image-actions {
      display: flex;
      flex-direction: column;
      gap: 0.2rem;
      font-size: 0.75rem;
      color: var(--muted);
    }

    .entry-field-label {
      font-size: 0.7rem;
      text-transform: uppercase;
      letter-spacing: 0.09em;
      color: var(--muted);
    }

    .entry-textarea {
      width: 100%;
      min-height: 80px;
      resize: none;
      border-radius: 7px;
      border: 1px solid rgba(55, 65, 106, 0.9);
      background: rgba(3, 6, 23, 0.9);
      color: var(--text);
      font-size: 0.8rem;
      padding: 0.35rem 0.4rem;
      font-family: var(--font-main);
    }

    .entry-footer {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-top: 0.15rem;
      font-size: 0.7rem;
      color: var(--muted);
      gap: 0.3rem;
    }

    .entry-footer-right {
      display: flex;
      gap: 0.25rem;
      align-items: center;
    }

    .pill {
      padding: 0.1rem 0.4rem;
      border-radius: 999px;
      background: rgba(3, 7, 23, 0.9);
      border: 1px solid rgba(55, 65, 106, 0.9);
    }

    .danger-link {
      color: var(--danger);
      cursor: pointer;
      text-decoration: none;
    }

    .danger-link:hover {
      text-decoration: underline;
    }

    .empty-state {
      grid-column: 1 / -1;
      text-align: center;
      padding: 1.2rem 0.8rem;
      color: var(--muted);
      border-radius: var(--radius);
      border: 1px dashed rgba(55, 65, 106, 0.9);
      background: radial-gradient(circle at top, rgba(255, 179, 71, 0.07), transparent 60%);
      font-size: 0.8rem;
    }

    .empty-state strong {
      color: var(--text);
    }

    .note-area {
      width: 100%;
      min-height: 300px;
      resize: none;
      border-radius: 8px;
      border: 1px solid rgba(55, 65, 106, 0.9);
      background: rgba(3, 6, 23, 0.98);
      color: var(--text);
      padding: 0.55rem 0.6rem;
      font-size: 0.85rem;
      font-family: var(--font-main);
    }

    .notes-list {
      display: flex;
      flex-direction: column;
      gap: 0.5rem;
      /* Let the notes list grow and then scroll within the panel */
      flex: 1;
      min-height: 0;
      overflow-y: auto;
    }

    /* Notes panel should fill the available space and allow its content to scroll */
    #notesPanel {
      display: flex;
      flex-direction: column;
      gap: 0.3rem;
      flex: 1;
      min-height: 0;
    }

    .note-card {
      background: radial-gradient(circle at top left, rgba(255, 179, 71, 0.05), transparent 55%),
                  linear-gradient(to bottom right, rgba(17, 24, 39, 0.98), rgba(12, 15, 32, 0.98));
      border-radius: var(--radius);
      border: 1px solid rgba(55, 65, 106, 0.9);
      box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
      padding: 0.5rem 0.6rem 0.45rem;
      display: flex;
      flex-direction: column;
      gap: 0.3rem;
    }

    .note-card.collapsed .note-body,
    .note-card.collapsed .note-footer {
      display: none;
    }

    .note-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 0.4rem;
    }

    .note-title-input {
      flex: 1;
      border: none;
      outline: none;
      background: transparent;
      color: var(--text);
      font-size: 0.9rem;
      font-weight: 600;
    }

    .note-meta {
      display: flex;
      gap: 0.25rem;
      font-size: 0.7rem;
      color: var(--muted);
    }

    .note-body {
      display: flex;
      flex-direction: column;
      gap: 0.25rem;
    }

    .note-image-wrapper {
      display: flex;
      align-items: center;
      gap: 0.4rem;
      margin-top: 0.2rem;
    }

    .note-image-preview {
      width: 72px;
      height: 72px;
      border-radius: 8px;
      object-fit: cover;
      border: 1px solid rgba(55, 65, 106, 0.9);
      background: rgba(15, 23, 42, 0.9);
    }

    .note-image-actions {
      display: flex;
      flex-direction: column;
      gap: 0.2rem;
      font-size: 0.75rem;
      color: var(--muted);
    }

    .image-modal-backdrop {
      position: fixed;
      inset: 0;
      background: rgba(0, 0, 0, 0.8);
      display: none;
      align-items: center;
      justify-content: center;
      z-index: 120;
    }

    .image-modal {
      max-width: 90vw;
      max-height: 90vh;
      border-radius: 12px;
      border: 1px solid rgba(55, 65, 106, 0.9);
      box-shadow: 0 24px 60px rgba(0, 0, 0, 0.8);
      background: #020617;
      padding: 0.4rem;
      display: flex;
      flex-direction: column;
      gap: 0.35rem;
      align-items: center;
    }

    .image-modal-img {
      max-width: 100%;
      max-height: 80vh;
      border-radius: 10px;
      object-fit: contain;
    }

    .image-modal-caption {
      font-size: 0.78rem;
      color: var(--muted);
    }

    .note-label {
      font-size: 0.75rem;
      text-transform: uppercase;
      letter-spacing: 0.1em;
      color: var(--muted);
      margin-bottom: 0.2rem;
    }

    .note-footer {
      margin-top: 0.25rem;
      font-size: 0.7rem;
      color: var(--muted);
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 0.3rem;
    }

    .note-footer span {
      opacity: 0.9;
    }

    .writing-layout {
      display: flex;
      flex: 1;
      min-height: 0;
      gap: 0.8rem;
    }

    .writing-sidebar {
      width: 230px;
      max-width: 40%;
      border-radius: var(--radius);
      border: 1px solid rgba(55, 65, 106, 0.9);
      background: radial-gradient(circle at top left, rgba(255, 179, 71, 0.06), transparent 55%),
                  linear-gradient(to bottom right, rgba(12, 17, 34, 0.98), rgba(7, 10, 24, 0.98));
      padding: 0.55rem 0.6rem 05.5rem;
      display: flex;
      flex-direction: column;
      gap: 0.45rem;
      font-size: 0.8rem;
      /* Allow internal scrolling layout so footer can stick to bottom */
      min-height: 0;
      max-height: calc(100vh - 140px);
      overflow-y: hidden;
    }

    .writing-sidebar-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 0.4rem;
    }

    .writing-sidebar-actions {
      display: inline-flex;
      gap: 0.25rem;
      align-items: center;
    }

    .writing-sidebar-title {
      font-size: 0.8rem;
      text-transform: uppercase;
      letter-spacing: 0.11em;
      color: var(--muted);
    }

    .writing-select {
      width: 100%;
      border-radius: 999px;
      border: 1px solid var(--border);
      background: rgba(3, 6, 23, 0.95);
      color: var(--text);
      font-size: 0.8rem;
      padding: 0.22rem 0.55rem;
    }

    .writing-list {
      list-style: none;
      margin: 0;
      padding: 0;
      display: flex;
      flex-direction: column;
      gap: 0.15rem;
      /* Let the chapter list take remaining space and scroll within the sidebar */
      flex: 1 1 auto;
      min-height: 0;
      overflow-y: auto;
    }

    .writing-list-total {
      /* Stick this summary section to the bottom of the sidebar */
      margin-top: auto;
      padding-top: 0.25rem;
      border-top: 1px dashed rgba(55, 65, 106, 0.8);
      font-size: 0.75rem;
      color: var(--muted);
    }

    .writing-list-item {
      font-size: 0.78rem;
      padding: 0.2rem 0.35rem;
      border-radius: 999px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 0.3rem;
      cursor: pointer;
      color: var(--muted);
      border: 1px solid transparent;
    }

    .writing-list-item.active {
      background: rgba(255, 179, 71, 0.12);
      border-color: rgba(255, 179, 71, 0.5);
      color: var(--text);
    }

    .writing-list-item.drag-over {
      border-color: rgba(255, 179, 71, 0.8);
      background: rgba(255, 179, 71, 0.18);
    }

    .writing-list-item:hover {
      background: rgba(39, 47, 85, 0.9);
      color: var(--text);
    }

    .writing-list-count {
      font-size: 0.7rem;
      padding: 0.05rem 0.35rem;
      border-radius: 999px;
      background: rgba(3, 6, 23, 0.9);
      border: 1px solid rgba(55, 65, 106, 0.9);
    }

    .writing-editor-container {
      flex: 1;
      min-width: 0;
      display: flex;
      flex-direction: column;
      gap: 0.35rem;
      min-height: 0;
    }

    .writing-toolbar {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      gap: 0.35rem;
      font-size: 0.8rem;
      color: var(--muted);
    }

    .writing-toolbar-group {
      display: inline-flex;
      align-items: center;
      gap: 0.25rem;
    }

    .writing-toolbar label {
      font-size: 0.72rem;
      text-transform: uppercase;
      letter-spacing: 0.08em;
      color: var(--muted);
    }

    .writing-toolbar select,
    .writing-toolbar button {
      border-radius: 999px;
      border: 1px solid var(--border);
      background: rgba(3, 6, 23, 0.95);
      color: var(--text);
      font-size: 0.8rem;
      padding: 0.2rem 0.5rem;
      cursor: pointer;
    }

    .writing-toolbar button {
      background: rgba(10, 15, 35, 0.9);
      display: inline-flex;
      align-items: center;
      justify-content: center;
      min-width: 1.6rem;
    }

    .writing-toolbar button.active {
      background: var(--accent-soft);
      border-color: rgba(255, 179, 71, 0.7);
    }

    .rich-editor {
      min-height: 300px;
      height: 500px;
      max-height: none;
      resize: vertical;
      border-radius: 10px;
      border: 1px solid rgba(55, 65, 106, 0.9);
      background: rgba(3, 6, 23, 0.98);
      color: var(--text);
      padding: 0.6rem 0.7rem;
      font-size: 0.9rem;
      line-height: 1.5;
      font-family: var(--font-main);
      box-shadow: 0 10px 24px rgba(0, 0, 0, 0.5);
      overflow-y: auto;
      outline: none;
      white-space: pre-wrap;
      word-wrap: break-word;
    }

    /* Legacy class kept for backwards compatibility; no longer used for the main editor */
    .writing-textarea {
      display: none;
    }

    .writing-editor-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 0.4rem;
      flex-wrap: wrap;
      font-size: 0.8rem;
      color: var(--muted);
    }

    .writing-editor-title-row {
      display: flex;
      gap: 0.4rem;
      flex-wrap: wrap;
      align-items: center;
    }

    .writing-field-label {
      font-size: 0.72rem;
      text-transform: uppercase;
      letter-spacing: 0.08em;
      color: var(--muted);
    }

    .writing-field-input {
      border-radius: 999px;
      border: 1px solid var(--border);
      background: rgba(3, 6, 23, 0.95);
      color: var(--text);
      font-size: 0.8rem;
      padding: 0.25rem 0.6rem;
      min-width: 120px;
    }

    .writing-chapter-title-input {
      flex: 1;
      min-width: 120px;
    }

    .writing-textarea {
      min-height: 500px;
      resize: vertical;
      border-radius: 10px;
      border: 1px solid rgba(55, 65, 106, 0.9);
      background: rgba(3, 6, 23, 0.98);
      color: var(--text);
      padding: 0.6rem 0.7rem;
      font-size: 0.9rem;
      line-height: 1.5;
      font-family: var(--font-mono);
      box-shadow: 0 10px 24px rgba(0, 0, 0, 0.5);
    }

    .writing-footer {
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 0.4rem;
      font-size: 0.75rem;
      color: var(--muted);
    }

    .writing-preview {
      margin-top: 0.25rem;
      font-size: 0.78rem;
      color: var(--muted);
      padding: 0.4rem 0.45rem;
      border-radius: 8px;
      border: 1px dashed rgba(55, 65, 106, 0.9);
      background: rgba(5, 10, 30, 0.95);
      max-height: 120px;
      overflow-y: auto;
    }

    .writing-preview-title {
      font-size: 0.7rem;
      text-transform: uppercase;
      letter-spacing: 0.08em;
      margin-bottom: 0.2rem;
      color: var(--muted);
    }

    .char-tag {
      color: var(--accent);
      border-bottom: 1px dotted rgba(255, 179, 71, 0.7);
      cursor: help;
      white-space: nowrap;
    }

    .writing-word-count {
      opacity: 0.9;
    }

    .writing-status {
      display: inline-flex;
      align-items: center;
      gap: 0.25rem;
    }

    .writing-status-dot {
      width: 6px;
      height: 6px;
      border-radius: 999px;
      background: #22c55e;
      box-shadow: 0 0 6px rgba(34, 197, 94, 0.7);
    }

    .main-resize-handle {
      width: 4px;
      background: linear-gradient(to bottom, rgba(39, 47, 85, 0.2), rgba(39, 47, 85, 0.6));
      cursor: col-resize;
      flex: 0 0 auto;
    }

    .main-resize-handle:hover {
      background: linear-gradient(to bottom, rgba(255, 179, 71, 0.3), rgba(39, 47, 85, 0.8));
    }

    .writing-resize-handle {
      width: 4px;
      background: linear-gradient(to bottom, rgba(39, 47, 85, 0.2), rgba(39, 47, 85, 0.6));
      cursor: col-resize;
      flex: 0 0 auto;
    }

    .writing-resize-handle:hover {
      background: linear-gradient(to bottom, rgba(255, 179, 71, 0.3), rgba(39, 47, 85, 0.8));
    }

    .pill-dot {
      position: fixed;
      inset: 0;
      background: rgba(0, 0, 0, 0.6);
      display: none;
      align-items: center;
      justify-content: center;
      z-index: 40;
    }

    .project-modal {
      width: min(420px, 90vw);
      background: radial-gradient(circle at top, rgba(255, 179, 71, 0.08), transparent 65%),
                  linear-gradient(to bottom right, #0b1020, #050713);
      border-radius: 12px;
      border: 1px solid rgba(55, 65, 106, 0.9);
      box-shadow: 0 18px 40px rgba(0, 0, 0, 0.6);
      padding: 0.9rem 1rem 0.8rem;
      display: flex;
      flex-direction: column;
      gap: 0.5rem;
      color: var(--text);
      font-size: 0.85rem;
    }

    .project-modal-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 0.4rem;
    }

    .project-modal-title {
      font-size: 0.9rem;
      text-transform: uppercase;
      letter-spacing: 0.12em;
      color: var(--muted);
    }

    .project-modal-body {
      max-height: 260px;
      overflow-y: auto;
      display: flex;
      flex-direction: column;
      gap: 0.35rem;
      padding-right: 0.2rem;
    }

    .project-item {
      border-radius: 8px;
      border: 1px solid rgba(55, 65, 106, 0.9);
      background: rgba(12, 16, 35, 0.98);
      padding: 0.35rem 0.4rem;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 0.35rem;
    }

    .project-item-main {
      display: flex;
      flex-direction: column;
      gap: 0.1rem;
      flex: 1;
      min-width: 0;
    }

    .project-item-name {
      font-size: 0.82rem;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .project-item-meta {
      font-size: 0.7rem;
      color: var(--muted);
    }

    .project-item-actions {
      display: flex;
      gap: 0.25rem;
    }

    .project-modal-footer {
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 0.4rem;
      margin-top: 0.2rem;
      font-size: 0.75rem;
      color: var(--muted);
    }

    .entry-modal {
      max-width: 640px;
    }

    .entry-modal-body {
      margin-top: 0.4rem;
      max-height: 360px;
      overflow-y: auto;
      padding-right: 0.2rem;
    }

    .splash-backdrop {
      position: fixed;
      inset: 0;
      background: radial-gradient(circle at top, rgba(15, 23, 42, 0.95), rgba(3, 7, 18, 0.98));
      display: flex;
      align-items: center;
      justify-content: center;
      z-index: 100;
    }

    .splash {
      width: min(520px, 94vw);
      border-radius: 14px;
      border: 1px solid rgba(55, 65, 106, 0.9);
      box-shadow: 0 24px 60px rgba(0, 0, 0, 0.7);
      padding: 1rem 1.1rem 0.9rem;
      background: radial-gradient(circle at top, rgba(255, 179, 71, 0.12), transparent 60%),
                  linear-gradient(to bottom right, #020617, #020617);
      display: flex;
      flex-direction: column;
      gap: 0.7rem;
      color: var(--text);
    }

    .splash-title {
      font-size: 1rem;
      text-transform: uppercase;
      letter-spacing: 0.14em;
      color: var(--muted);
    }

    .splash-text {
      font-size: 0.8rem;
      color: var(--muted);
      line-height: 1.5;
    }

    .splash-strong {
      color: var(--accent);
    }

    .splash-layout {
      display: grid;
      grid-template-columns: minmax(0, 1.3fr) minmax(0, 1.2fr);
      gap: 0.8rem;
    }

    .profile-list {
      display: flex;
      flex-direction: column;
      gap: 0.4rem;
      max-height: 220px;
      overflow-y: auto;
      padding-right: 0.2rem;
    }

    .profile-item {
      border-radius: 10px;
      border: 1px solid rgba(55, 65, 106, 0.9);
      background: rgba(15, 23, 42, 0.9);
      padding: 0.4rem 0.45rem;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 0.4rem;
      font-size: 0.8rem;
    }

    .profile-item-main {
      display: flex;
      flex-direction: column;
      gap: 0.1rem;
      min-width: 0;
    }

    .profile-item-name {
      font-weight: 600;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .profile-item-meta {
      font-size: 0.7rem;
      color: var(--muted);
    }

    .splash-form {
      display: flex;
      flex-direction: column;
      gap: 0.35rem;
      font-size: 0.8rem;
    }

    .splash-input {
      border-radius: 999px;
      border: 1px solid var(--border);
      background: rgba(3, 6, 23, 0.98);
      color: var(--text);
      font-size: 0.8rem;
      padding: 0.3rem 0.65rem;
      width: 100%;
    }

    .pill-dot {
      width: 6px;
      height: 6px;
      border-radius: 999px;
      background: #22c55e;
      display: inline-block;
      margin-right: 0.2rem;
      box-shadow: 0 0 6px rgba(34, 197, 94, 0.7);
    }

    body.mobile-mode header {
      padding: 0.8rem 0.9rem;
      align-items: stretch;
      flex-direction: column;
      gap: 0.75rem;
    }

    body.mobile-mode .header-actions {
      width: 100%;
      justify-content: flex-start;
      overflow-x: auto;
      flex-wrap: nowrap;
      padding-bottom: 0.15rem;
    }

    body.mobile-mode main {
      flex-direction: column;
    }

    body.mobile-mode .sidebar {
      display: none;
    }

    body.mobile-mode .sidebar-footer {
      width: 100%;
    }

    body.mobile-mode .main-resize-handle,
    body.mobile-mode .writing-resize-handle {
      display: none;
    }

    body.mobile-mode .section-tabs {
      display: flex;
      overflow-x: auto;
      gap: 0.35rem;
      padding: 0.55rem 0.7rem 0;
      border-bottom: 1px solid rgba(55, 65, 106, 0.7);
      background: rgba(11, 16, 32, 0.92);
    }

    body.mobile-mode .section-container {
      padding: 0.7rem;
    }

    body.mobile-mode .section-header,
    body.mobile-mode .entries-toolbar,
    body.mobile-mode .writing-editor-title-row,
    body.mobile-mode .writing-toolbar,
    body.mobile-mode .entry-header,
    body.mobile-mode .entry-footer {
      flex-direction: column;
      align-items: stretch;
    }

    body.mobile-mode .entry-header-left,
    body.mobile-mode .entry-footer-right {
      width: 100%;
      align-items: flex-start;
      flex-wrap: wrap;
    }

    body.mobile-mode .entry-meta {
      width: 100%;
      margin-top: 0.25rem;
      gap: 0.35rem;
    }

    body.mobile-mode .location-parent-select {
      max-width: 100%;
    }

    body.mobile-mode .entries-toolbar > *,
    body.mobile-mode .writing-toolbar-group,
    body.mobile-mode .project-title-input,
    body.mobile-mode .project-select,
    body.mobile-mode #searchInput,
    body.mobile-mode #chapterVolumeMoveSelect,
    body.mobile-mode #volumeLabelInput,
    body.mobile-mode #chapterLabelInput,
    body.mobile-mode #chapterTitleInput,
    body.mobile-mode .entry-title-input {
      width: 100%;
      max-width: none;
    }

    body.mobile-mode .writing-layout {
      flex-direction: column;
    }

    body.mobile-mode .writing-sidebar {
      width: 100% !important;
      max-height: 36vh;
    }

    body.mobile-mode .project-modal {
      width: min(96vw, 520px);
      max-height: 88vh;
    }

    body.mobile-mode .tab {
      flex: 0 0 auto;
    }

    body.mobile-mode .tab .btn.small {
      align-self: center;
    }

    @media (max-width: 800px) {
      main {
        flex-direction: column;
      }

      .sidebar {
        width: 100%;
        max-width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border);
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
      }

      .sidebar-footer {
        width: 100%;
      }
    }
  