/* BoyceLab Content Studio 5.1 — spacious writing workspace */
.cms-dashboard {
  grid-template-columns: 220px minmax(0, 1fr);
}

.cms-workspace {
  padding: 0 24px 56px;
}

.cms-topbar {
  min-height: 88px;
}

.topbar-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.topbar-button {
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(103, 232, 249, 0.035);
  color: var(--muted);
  cursor: pointer;
}

.topbar-button:hover,
.topbar-button.active {
  border-color: var(--line-strong);
  background: rgba(103, 232, 249, 0.08);
  color: var(--cyan);
}

.cms-layout {
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 18px;
  max-width: 1800px;
  margin: 0 auto;
  padding-top: 18px;
}

.post-library,
.editor-shell {
  border-radius: 16px;
  box-shadow: 0 18px 55px rgba(0, 0, 0, 0.24);
}

.post-library {
  top: 16px;
  max-height: calc(100vh - 32px);
}

.editor-heading {
  position: relative;
  z-index: 1;
  top: auto;
  padding: 20px 24px;
  background: rgba(9, 24, 32, 0.94);
  backdrop-filter: blur(20px);
}

.editor-heading > div:first-child {
  min-width: 0;
}

.editor-heading h2 {
  overflow: hidden;
  max-width: 680px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.locale-workbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(7, 21, 28, 0.48);
}

.locale-workbar .locale-tabs {
  min-width: 0;
  padding: 0;
  border: 0;
}

.auto-translate-button {
  flex: 0 0 auto;
  min-height: 40px;
  padding: 0 13px;
  border: 1px solid rgba(167, 139, 250, 0.25);
  border-radius: 10px;
  background: rgba(167, 139, 250, 0.07);
  color: #c4b5fd;
  cursor: pointer;
}

.auto-translate-button span {
  color: var(--cyan);
}

.auto-translate-button:hover:not(:disabled) {
  border-color: rgba(167, 139, 250, 0.5);
  background: rgba(167, 139, 250, 0.13);
}

.auto-translate-button:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.translation-hint {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin: 16px 24px 0;
  padding: 12px 14px;
  border: 1px solid rgba(167, 139, 250, 0.16);
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(167, 139, 250, 0.055), rgba(103, 232, 249, 0.025));
}

.translation-hint span {
  flex: 0 0 auto;
  color: #a78bfa;
  font-size: 0.62rem;
  letter-spacing: 0.14em;
}

.translation-hint p {
  margin: 0;
  color: var(--faint);
  font-size: 0.7rem;
  line-height: 1.65;
}

.editor-grid {
  display: block;
  padding: 22px 24px 30px;
}

.content-column {
  width: min(100%, 1040px);
  margin: 0 auto;
}

.large-field input {
  min-height: 62px;
  padding-inline: 16px;
  font-size: clamp(1.15rem, 2vw, 1.45rem);
}

.field textarea {
  line-height: 1.7;
}

.rich-editor-card {
  border-color: var(--line-strong);
  border-radius: 16px;
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.18);
}

.editor-toolbar {
  top: 87px;
  padding: 9px 10px;
  background: rgba(9, 26, 34, 0.97);
  backdrop-filter: blur(16px);
}

.rich-editor {
  min-height: 680px;
  padding: 34px clamp(22px, 5vw, 58px);
  font-size: 1.04rem;
  line-height: 1.92;
}

.seo-panel {
  margin-top: 20px;
}

.settings-column {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(260px, 0.9fr);
  gap: 16px;
  width: min(100%, 1040px);
  margin: 20px auto 0;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.settings-card {
  padding: 20px;
}

.publication-card {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 16px;
}

.publication-card header,
.publication-card .field:first-of-type,
.publication-card .field:last-of-type {
  grid-column: 1 / -1;
}

.visual-card {
  grid-column: 2;
  grid-row: 1 / span 2;
}

.danger-card {
  grid-column: 1;
  align-self: start;
}

.cover-preview {
  min-height: 190px;
}

.cover-preview img {
  height: 220px;
}

.cms-dashboard.library-collapsed .cms-layout {
  grid-template-columns: minmax(0, 1fr);
}

.cms-dashboard.library-collapsed .post-library {
  display: none;
}

.cms-dashboard.focus-mode {
  grid-template-columns: minmax(0, 1fr);
}

.cms-dashboard.focus-mode .cms-sidebar,
.cms-dashboard.focus-mode .post-library,
.cms-dashboard.focus-mode .settings-column,
.cms-dashboard.focus-mode .translation-hint {
  display: none;
}

.cms-dashboard.focus-mode .cms-workspace {
  padding-inline: clamp(18px, 5vw, 80px);
}

.cms-dashboard.focus-mode .cms-layout {
  grid-template-columns: minmax(0, 1fr);
  max-width: 1220px;
}

.cms-dashboard.focus-mode .content-column {
  width: min(100%, 1120px);
}

@media (max-width: 1280px) {
  .cms-dashboard {
    display: block;
  }

  .cms-sidebar {
    position: sticky;
    z-index: 30;
    top: 0;
    width: 100%;
    height: auto;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 14px;
    padding: 9px 13px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .cms-brand {
    margin: 0;
  }

  .cms-brand span,
  .edge-card,
  .sidebar-action {
    display: none;
  }

  .cms-nav {
    display: flex;
    justify-content: flex-end;
    overflow: auto;
  }

  .cms-nav a {
    grid-template-columns: auto 1fr;
    min-height: 40px;
    padding: 0 10px;
    font-size: 0.75rem;
  }

  .cms-workspace {
    padding: 0 18px 42px;
  }

  .editor-heading {
    top: auto;
  }

  .editor-toolbar {
    top: 58px;
  }
}

@media (max-width: 1040px) {
  .cms-layout {
    grid-template-columns: 1fr;
  }

  .post-library {
    position: static;
    max-height: none;
  }

  .post-list {
    max-height: 300px;
  }

  .cms-dashboard:not(.library-open) .post-library {
    display: none;
  }

  .cms-dashboard.library-open .post-library,
  .cms-dashboard.library-collapsed .post-library {
    display: block;
  }

  .editor-heading {
    position: relative;
    top: auto;
  }

  .editor-toolbar {
    top: 58px;
  }
}

@media (max-width: 760px) {
  .cms-workspace {
    padding: 0 10px 28px;
  }

  .cms-topbar {
    align-items: flex-start;
    min-height: auto;
    padding: 16px 4px;
  }

  .cms-topbar .cms-eyebrow {
    display: none;
  }

  .cms-topbar h1 {
    margin: 0;
    font-size: 1.2rem;
  }

  .topbar-actions {
    gap: 6px;
  }

  .topbar-button {
    min-height: 38px;
    padding: 0 9px;
    font-size: 0.72rem;
  }

  .locale-workbar {
    align-items: stretch;
    flex-direction: column;
    padding: 10px 12px;
  }

  .locale-workbar .locale-tabs {
    width: 100%;
  }

  .locale-tab {
    flex: 1;
    justify-content: center;
    padding-inline: 8px;
  }

  .auto-translate-button {
    width: 100%;
  }

  .translation-hint {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
    margin: 12px 14px 0;
  }

  .editor-grid {
    padding: 16px 14px 22px;
  }

  .rich-editor {
    min-height: 500px;
    padding: 24px 17px;
  }

  .settings-column {
    grid-template-columns: 1fr;
  }

  .publication-card {
    display: block;
  }

  .visual-card,
  .danger-card {
    grid-column: auto;
    grid-row: auto;
  }

  .cms-dashboard.focus-mode .cms-workspace {
    padding-inline: 10px;
  }
}

@media (max-width: 520px) {
  .cms-nav a {
    padding: 0 7px;
    font-size: 0.68rem;
  }

  .editor-actions {
    grid-template-columns: 1fr 1fr 1fr;
  }

  .editor-actions .primary {
    grid-column: auto;
  }

  .editor-actions .button {
    padding-inline: 8px;
    font-size: 0.75rem;
  }

  .locale-tab span {
    font-size: 0.72rem;
  }

  .translation-hint {
    display: none;
  }
}

/* Tiptap writing surface */
.editor-toolbar {
  position: relative;
  top: auto;
  z-index: 2;
  gap: 8px;
  padding: 10px 12px;
  background: rgba(9, 26, 34, 0.98);
}

.editor-toolbar button {
  min-width: 38px;
  padding: 0 10px;
  white-space: nowrap;
}

.editor-toolbar button.active,
.editor-toolbar button[aria-pressed="true"] {
  border-color: rgba(103, 232, 249, 0.34);
  background: rgba(103, 232, 249, 0.12);
  color: var(--cyan);
  box-shadow: inset 0 0 0 1px rgba(103, 232, 249, 0.08);
}

.editor-toolbar button:disabled {
  opacity: 0.28;
  cursor: not-allowed;
}

.insert-tools {
  margin-left: auto;
  padding-right: 0;
  border-right: 0;
}

.rich-editor {
  min-height: 0;
  padding: 0;
  font-size: inherit;
  line-height: inherit;
}

.rich-editor .boyce-prosemirror {
  min-height: 680px;
  padding: 38px clamp(24px, 6vw, 72px) 96px;
  color: #d9edf2;
  font-family: "Noto Sans TC", system-ui, sans-serif;
  font-size: 1.04rem;
  line-height: 1.92;
  outline: none;
  overflow-wrap: anywhere;
  caret-color: var(--cyan);
}

.rich-editor .boyce-prosemirror:focus {
  background: linear-gradient(180deg, rgba(103, 232, 249, 0.018), transparent 180px);
}

.rich-editor .boyce-prosemirror p {
  min-height: 1.45em;
  margin: 0 0 1em;
}

.rich-editor .boyce-prosemirror p.is-editor-empty:first-child::before {
  float: left;
  height: 0;
  color: #4e6771;
  content: attr(data-placeholder);
  pointer-events: none;
}

.rich-editor .boyce-prosemirror h2,
.rich-editor .boyce-prosemirror h3 {
  scroll-margin-top: 24px;
}

.rich-editor .boyce-prosemirror hr {
  margin: 2.1em 0;
  border: 0;
  border-top: 1px solid rgba(103, 232, 249, 0.22);
}

.rich-editor .boyce-prosemirror ul,
.rich-editor .boyce-prosemirror ol {
  padding-left: 1.6em;
}

.rich-editor .boyce-prosemirror > [data-resize-container] {
  max-width: 100%;
  justify-content: center;
  margin: 26px 0;
}

.rich-editor .boyce-prosemirror > [data-resize-container]:has(img[data-align="left"]) {
  justify-content: flex-start;
}

.rich-editor .boyce-prosemirror > [data-resize-container]:has(img[data-align="right"]) {
  justify-content: flex-end;
}

.rich-editor [data-resize-wrapper] {
  max-width: 100%;
  border-radius: 13px;
}

.rich-editor [data-resize-wrapper] img {
  display: block;
  max-width: 100%;
  border-radius: 12px;
  box-shadow: 0 16px 45px rgba(0, 0, 0, 0.24);
}

.rich-editor [data-resize-container].ProseMirror-selectednode [data-resize-wrapper] {
  outline: 2px solid var(--cyan);
  outline-offset: 5px;
}

.rich-editor [data-resize-handle] {
  z-index: 3;
  width: 15px;
  height: 15px;
  border: 2px solid #07151c;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 0 2px rgba(103, 232, 249, 0.32), 0 0 18px rgba(103, 232, 249, 0.62);
}

.rich-editor [data-resize-handle*="top"] { margin-top: -7px; }
.rich-editor [data-resize-handle*="bottom"] { margin-bottom: -7px; }
.rich-editor [data-resize-handle*="left"] { margin-left: -7px; }
.rich-editor [data-resize-handle*="right"] { margin-right: -7px; }
.rich-editor [data-resize-handle="top-left"],
.rich-editor [data-resize-handle="bottom-right"] { cursor: nwse-resize; }
.rich-editor [data-resize-handle="top-right"],
.rich-editor [data-resize-handle="bottom-left"] { cursor: nesw-resize; }

.image-inspector {
  display: grid;
  grid-template-columns: auto auto minmax(190px, 1fr) auto minmax(180px, 1.2fr) auto;
  align-items: end;
  gap: 10px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(90deg, rgba(103, 232, 249, 0.075), rgba(167, 139, 250, 0.035));
}

.image-inspector[hidden] {
  display: none;
}

.image-inspector-heading {
  display: grid;
  align-self: center;
  gap: 3px;
}

.image-inspector-heading span {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--text);
  font-size: 0.72rem;
  font-weight: 700;
}

.image-inspector-heading i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 12px var(--cyan);
}

.image-inspector-heading small {
  color: var(--faint);
  font-size: 0.59rem;
}

.image-preset-group,
.image-align-group {
  display: flex;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 9px;
}

.image-preset-group button,
.image-align-group button {
  min-width: 36px;
  height: 36px;
  padding: 0 9px;
  border: 0;
  border-right: 1px solid var(--line);
  background: rgba(7, 21, 28, 0.72);
  color: var(--muted);
  cursor: pointer;
}

.image-preset-group button:last-child,
.image-align-group button:last-child {
  border-right: 0;
}

.image-preset-group button:hover,
.image-align-group button:hover,
.image-align-group button.active {
  background: rgba(103, 232, 249, 0.1);
  color: var(--cyan);
}

.image-width-control,
.image-alt-control {
  display: grid;
  gap: 5px;
  color: var(--faint);
  font-size: 0.62rem;
}

.image-width-control span {
  display: flex;
  justify-content: space-between;
}

.image-width-control b {
  color: var(--cyan);
  font-weight: 600;
}

.image-width-control input {
  width: 100%;
  accent-color: var(--cyan);
}

.image-alt-control input {
  width: 100%;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #07151c;
  color: var(--text);
  padding: 0 10px;
  outline: none;
}

.image-alt-control input:focus {
  border-color: var(--cyan);
}

.remove-image-button {
  height: 36px;
  padding: 0 11px;
  border: 1px solid rgba(251, 113, 133, 0.24);
  border-radius: 9px;
  background: rgba(251, 113, 133, 0.06);
  color: var(--red);
  cursor: pointer;
}

.editor-footer {
  align-items: center;
  flex-wrap: wrap;
}

.editor-shortcuts {
  margin-inline: auto;
}

.editor-shortcuts kbd {
  padding: 2px 5px;
  border: 1px solid var(--line);
  border-bottom-color: var(--line-strong);
  border-radius: 5px;
  background: #07151c;
  color: var(--muted);
  font: inherit;
}

.link-dialog {
  width: min(92vw, 560px);
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  background: #091820;
  color: var(--text);
  box-shadow: 0 35px 120px rgba(0, 0, 0, 0.65);
}

.link-card > header,
.link-card > footer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}

.link-card > header {
  justify-content: space-between;
}

.link-card > header span {
  color: var(--cyan);
  font-size: 0.62rem;
  letter-spacing: 0.16em;
}

.link-card > header h2 {
  margin: 4px 0 0;
  font-size: 1rem;
}

.link-card > header button {
  width: 38px;
  height: 38px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 1.5rem;
  cursor: pointer;
}

.link-fields {
  padding: 20px;
}

.link-card > footer {
  justify-content: flex-end;
  border-top: 1px solid var(--line);
  border-bottom: 0;
}

.link-card > footer span {
  flex: 1;
}

.link-status {
  min-height: 18px;
  margin: 0;
  color: var(--red);
  font-size: 0.72rem;
}

.preview-content img[data-align="left"] { margin-right: auto; }
.preview-content img[data-align="center"] { display: block; margin-inline: auto; }
.preview-content img[data-align="right"] { display: block; margin-left: auto; }

@media (max-width: 1180px) {
  .image-inspector {
    grid-template-columns: auto auto minmax(180px, 1fr) auto;
  }

  .image-alt-control {
    grid-column: 1 / -2;
  }
}

@media (max-width: 760px) {
  .editor-toolbar {
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: thin;
  }

  .toolbar-group {
    flex: 0 0 auto;
  }

  .insert-tools {
    margin-left: 0;
  }

  .rich-editor .boyce-prosemirror {
    min-height: 520px;
    padding: 26px 18px 72px;
    font-size: 1rem;
  }

  .image-inspector {
    grid-template-columns: 1fr auto;
    align-items: center;
  }

  .image-inspector-heading,
  .image-width-control,
  .image-alt-control {
    grid-column: 1 / -1;
  }

  .image-alt-control {
    grid-row: auto;
  }

  .editor-shortcuts {
    display: none;
  }
}

@media (max-width: 430px) {
  .image-inspector {
    grid-template-columns: 1fr;
  }

  .image-inspector-heading,
  .image-width-control,
  .image-alt-control {
    grid-column: 1;
  }

  .image-preset-group,
  .image-align-group,
  .remove-image-button {
    width: 100%;
  }

  .image-preset-group button,
  .image-align-group button {
    flex: 1;
  }

  .link-card > footer {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .link-card > footer span {
    display: none;
  }
}

.cms-workspace,
.editor-shell,
.rich-editor-card,
.locale-workbar,
.post-library,
.slug-field input {
  min-width: 0;
}

.cms-dashboard :is(button, a, summary):focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 3px;
}

.cms-dashboard :is(button, input, select, textarea, summary) {
  scroll-margin-block: 100px;
}

.save-state {
  overflow-wrap: anywhere;
}

#postForm[aria-busy="true"] {
  opacity: 0.72;
}

.cms-dashboard.focus-mode .post-library {
  display: none;
}

.preview-content :is(pre, table),
.rich-editor .boyce-prosemirror pre {
  max-width: 100%;
  overflow-x: auto;
}

@media (min-width: 901px) and (max-width: 1280px) {
  .editor-heading {
    align-items: stretch;
    flex-direction: column;
    gap: 14px;
  }

  .editor-actions {
    justify-content: flex-start;
  }

  .settings-column {
    grid-template-columns: minmax(0, 1fr);
  }

  .visual-card,
  .danger-card {
    grid-column: auto;
    grid-row: auto;
  }
}

@media (max-width: 1280px) {
  .cms-sidebar {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }

  .cms-sidebar .sidebar-action {
    display: block;
    position: static;
    inset: auto;
    width: auto;
    max-width: 110px;
    min-height: 44px;
    margin: 0;
    padding: 8px;
    font-size: 0.68rem;
  }

  .cms-nav {
    min-width: 0;
  }

  .cms-nav a {
    flex-shrink: 0;
  }
}

@media (max-width: 760px) {
  .cms-topbar {
    flex-direction: column;
    gap: 12px;
  }

  .cms-sidebar {
    position: static;
  }

  .topbar-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .cms-topbar .save-state {
    display: block;
    flex: 1 0 100%;
    font-size: 0.75rem;
  }

  .topbar-button,
  .editor-toolbar button,
  .image-preset-group button,
  .image-align-group button,
  .remove-image-button {
    min-height: 44px;
  }

  .editor-shell,
  .rich-editor-card {
    overflow: visible;
  }

  .editor-toolbar {
    position: sticky;
    top: 0;
    z-index: 31;
    border-radius: 16px 16px 0 0;
  }

  .settings-card,
  .auth-card {
    padding: 18px;
  }

  .auth-dialog,
  .link-dialog {
    max-height: calc(100dvh - 24px);
    overflow-y: auto;
  }

  .toast-region {
    bottom: max(12px, env(safe-area-inset-bottom));
  }
}

@media (max-width: 430px) {
  .cms-sidebar {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .cms-sidebar .sidebar-action {
    grid-column: 1 / -1;
    justify-self: end;
    max-width: none;
    min-height: 36px;
  }

  .editor-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .editor-actions .primary {
    grid-column: 1 / -1;
  }

  .editor-heading {
    padding-inline: 14px;
  }
}
