* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: #fff; color: #111; font-family: Arial, Helvetica, sans-serif; }
body { min-height: 100vh; }
a { color: #111; text-decoration: none; }
.topbar { min-height: 68px; display: flex; justify-content: flex-end; align-items: center; gap: 28px; padding: 0 32px; border-bottom: 1px solid #f0f0f0; }
.language-switch, .account-actions { display: flex; align-items: center; gap: 14px; font-size: 14px; }
.language-switch { color: #aaa; gap: 6px; }
.lang { color: #aaa; }
.lang.active { color: #111; font-weight: 700; }
.account-actions a { padding: 9px 0; }
.account-actions .primary-link { padding: 9px 13px; border: 1px solid #111; border-radius: 7px; }
.user-name { font-weight: 600; }
.blank-main { min-height: calc(100vh - 68px); }
.auth-shell { min-height: calc(100vh - 68px); display: flex; justify-content: center; align-items: flex-start; padding: 64px 20px; }
.auth-card { width: 100%; max-width: 420px; }
.auth-card h1 { margin: 0 0 28px; font-size: 30px; font-weight: 650; }
.field { margin-bottom: 18px; }
.field label { display: block; margin-bottom: 8px; font-size: 13px; color: #555; }
.field input { width: 100%; height: 46px; padding: 0 12px; border: 1px solid #d9d9d9; border-radius: 7px; font-size: 15px; background: #fff; outline: none; }
.field input:focus { border-color: #777; }
.btn { width: 100%; height: 46px; border: 1px solid #111; border-radius: 7px; background: #111; color: #fff; font-size: 15px; cursor: pointer; }
.btn.secondary { margin-top: 10px; background: #fff; color: #111; }
.alert { margin: 0 0 20px; padding: 12px 14px; border-radius: 7px; font-size: 14px; line-height: 1.5; border: 1px solid #e1e1e1; background: #fafafa; }
.alert.error { border-color: #e6caca; background: #fff8f8; }
.alert.success { border-color: #cfe1d2; background: #f8fff9; }
.small-link { display: inline-block; margin-top: 18px; font-size: 13px; color: #666; }
.verify-email { margin: -14px 0 22px; color: #666; font-size: 14px; line-height: 1.5; word-break: break-all; }
.code-input { letter-spacing: 6px; text-align: center; font-size: 22px !important; font-weight: 700; }
@media (max-width: 640px) {
  .topbar { padding: 0 16px; gap: 16px; }
  .account-actions { gap: 10px; font-size: 13px; }
  .auth-shell { padding-top: 42px; }
}

/* Tez Yaz workspace */
button, textarea, input { font-family: inherit; }
button { appearance: none; }
.workspace-shell { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 48px 0 80px; }
.workspace-header, .project-page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 34px; }
.workspace-header h1, .project-page-header h1 { margin: 4px 0 0; font-size: clamp(30px, 4vw, 44px); line-height: 1.05; letter-spacing: -0.035em; font-weight: 650; }
.eyebrow { font-size: 12px; text-transform: uppercase; letter-spacing: .14em; color: #8a8a8a; font-weight: 700; }
.button-link { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 0 16px; border: 1px solid #d7d7d7; border-radius: 8px; background: #fff; color: #111; font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.button-link.dark { background: #111; border-color: #111; color: #fff; }
.empty-state { min-height: 260px; border: 1px dashed #dcdcdc; border-radius: 14px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; color: #666; }
.empty-state p { margin: 0; }
.project-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.project-card { display: block; border: 1px solid #e5e5e5; border-radius: 13px; padding: 22px; transition: border-color .15s ease, transform .15s ease; }
.project-card:hover { border-color: #bcbcbc; transform: translateY(-1px); }
.project-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.project-card h2 { margin: 0; font-size: 20px; line-height: 1.3; font-weight: 650; }
.status-pill { border-radius: 999px; padding: 5px 9px; background: #f3f3f3; color: #666; font-size: 11px; white-space: nowrap; }
.status-pill.active { background: #111; color: #fff; }
.project-stats { margin-top: 32px; color: #666; font-size: 13px; }
.project-stats strong { color: #111; font-size: 21px; margin-right: 5px; }
.project-dates { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-top: 20px; padding-top: 16px; border-top: 1px solid #f0f0f0; color: #888; font-size: 12px; }
.project-open { margin-top: 20px; font-size: 13px; font-weight: 650; }
.form-shell { min-height: calc(100vh - 68px); display: flex; justify-content: center; align-items: flex-start; padding: 64px 20px; }
.form-card { width: 100%; max-width: 520px; }
.form-card h1 { margin: 12px 0 28px; font-size: 34px; letter-spacing: -0.03em; }
.back-link { display: inline-block; color: #777; font-size: 13px; }
.meta-row { display: flex; flex-wrap: wrap; gap: 8px 22px; margin-top: 14px; color: #888; font-size: 12px; }
.builder-grid { display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); gap: 24px; align-items: start; }
.paste-panel, .sentence-panel { border: 1px solid #e6e6e6; border-radius: 14px; background: #fff; overflow: hidden; }
.paste-panel { padding: 22px; position: sticky; top: 20px; }
.panel-heading h2 { margin: 0; font-size: 20px; }
.panel-heading p { margin: 9px 0 20px; color: #777; font-size: 13px; line-height: 1.55; }
.paste-textarea { width: 100%; min-height: 430px; resize: vertical; padding: 15px; border: 1px solid #dcdcdc; border-radius: 9px; outline: none; font-size: 15px; line-height: 1.65; }
.paste-textarea:focus { border-color: #777; }
.btn.compact { width: auto; min-width: 120px; margin-top: 12px; padding: 0 22px; }
.sentence-panel-head { min-height: 92px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 18px 20px; border-bottom: 1px solid #ededed; }
.metric-label { color: #888; text-transform: uppercase; letter-spacing: .08em; font-size: 10px; font-weight: 700; }
.metric-number { margin-top: 2px; font-size: 32px; font-weight: 700; letter-spacing: -0.04em; }
.sentence-empty { padding: 42px 22px; color: #999; text-align: center; }
.sentence-list { max-height: 68vh; overflow: auto; padding: 0 20px 22px; }
.paragraph-label { position: sticky; top: 0; z-index: 1; margin: 0 -2px; padding: 18px 2px 8px; background: #fff; color: #8a8a8a; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.sentence-preview-row { display: grid; grid-template-columns: 58px 1fr; gap: 12px; padding: 12px 0; border-bottom: 1px solid #f2f2f2; }
.sentence-preview-row:last-child { border-bottom: 0; }
.sentence-number { padding-top: 3px; color: #999; font-size: 11px; font-variant-numeric: tabular-nums; }
.sentence-preview-row p { margin: 0; font-size: 14px; line-height: 1.65; color: #222; }
.editor-head { margin-bottom: 24px; }
.editor-help { max-width: 660px; margin: 12px 0 0; color: #777; font-size: 13px; line-height: 1.55; }
.editor-list-wrap { max-width: 900px; margin: 0 auto; }
.editor-paragraph-title { margin: 34px 0 10px; color: #777; font-size: 12px; text-transform: uppercase; letter-spacing: .1em; font-weight: 700; }
.editor-paragraph-title:first-child { margin-top: 0; }
.editor-sentence { scroll-margin-top: 20px; border: 1px solid #e7e7e7; border-radius: 12px; padding: 16px; margin-bottom: 10px; }
.editor-sentence:target { border-color: #aaa; }
.editor-sentence-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.editor-sentence-meta strong { font-size: 12px; }
.editor-sentence-meta span { color: #999; font-size: 11px; }
.sentence-edit-textarea { width: 100%; min-height: 74px; resize: none; overflow: hidden; border: 1px solid #e0e0e0; border-radius: 8px; padding: 12px; outline: none; font-size: 15px; line-height: 1.65; }
.sentence-edit-textarea:focus { border-color: #888; }
.sentence-actions { display: flex; justify-content: flex-end; margin-top: 9px; }
.mini-btn { min-height: 34px; padding: 0 12px; border: 1px solid #d8d8d8; border-radius: 7px; background: #fff; color: #111; cursor: pointer; font-size: 12px; font-weight: 600; }
.mini-btn.dark { background: #111; border-color: #111; color: #fff; }
.row-secondary-actions { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-top: 10px; padding-top: 10px; border-top: 1px solid #f2f2f2; }
.row-secondary-actions details { flex: 1; }
.row-secondary-actions summary, .new-paragraph-box summary { cursor: pointer; color: #666; font-size: 12px; user-select: none; }
.inline-add-form { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-top: 10px; }
.inline-add-form textarea { width: 100%; min-height: 68px; resize: vertical; border: 1px solid #ddd; border-radius: 7px; padding: 10px; outline: none; font-size: 13px; line-height: 1.5; }
.text-danger-btn { border: 0; background: transparent; padding: 2px 0; color: #a14c4c; cursor: pointer; font-size: 12px; }
.new-paragraph-box { margin: 28px 0 0; padding: 16px; border: 1px dashed #d7d7d7; border-radius: 10px; }
.paragraph-add-form { margin-top: 14px; }
@media (max-width: 820px) {
  .project-grid { grid-template-columns: 1fr; }
  .builder-grid { grid-template-columns: 1fr; }
  .paste-panel { position: static; }
  .paste-textarea { min-height: 280px; }
  .sentence-list { max-height: none; }
}
@media (max-width: 640px) {
  .workspace-shell { width: min(100% - 28px, 1180px); padding-top: 32px; }
  .workspace-header, .project-page-header { flex-direction: column; }
  .sentence-panel-head { align-items: flex-start; flex-direction: column; }
  .sentence-preview-row { grid-template-columns: 48px 1fr; gap: 8px; }
  .inline-add-form { grid-template-columns: 1fr; }
  .editor-sentence-meta { align-items: flex-start; flex-direction: column; }
}

/* Paragraph-first project loader */
.is-hidden { display: none !important; }
.paragraph-builder-grid { display: grid; grid-template-columns: minmax(0, 1fr) 285px; gap: 24px; align-items: start; }
.paragraph-work-panel { min-height: 520px; border: 1px solid #e6e6e6; border-radius: 14px; background: #fff; padding: 24px; }
.paragraph-welcome { min-height: 430px; display: flex; flex-direction: column; justify-content: center; align-items: flex-start; max-width: 620px; margin: 0 auto; }
.paragraph-welcome h2 { margin: 7px 0 10px; font-size: 30px; letter-spacing: -.025em; }
.paragraph-welcome p { margin: 0 0 22px; color: #777; font-size: 14px; line-height: 1.65; max-width: 560px; }
.paragraph-composer-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.paragraph-composer-head h2 { margin: 4px 0 0; font-size: 32px; letter-spacing: -.035em; }
.draft-count { color: #777; font-size: 12px; font-variant-numeric: tabular-nums; }
.paragraph-input { min-height: 250px; }
.paragraph-primary-actions { display: flex; justify-content: flex-end; margin-top: 12px; }
.inline-error { margin-top: 12px; color: #9b3737; font-size: 13px; }
.paragraph-preview { margin-top: 28px; padding-top: 22px; border-top: 1px solid #ededed; }
.paragraph-preview-title { margin-bottom: 8px; font-size: 12px; font-weight: 750; letter-spacing: .08em; color: #666; }
.paragraph-preview-list { border-top: 1px solid #f0f0f0; }
.paragraph-sentence-row { display: grid; grid-template-columns: 46px 1fr; gap: 12px; padding: 13px 0; border-bottom: 1px solid #f0f0f0; }
.paragraph-sentence-number { padding-top: 2px; color: #777; font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }
.paragraph-sentence-row p { margin: 0; color: #222; font-size: 14px; line-height: 1.65; }
.paragraph-save-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 18px; flex-wrap: wrap; }
.paragraph-map-panel { position: sticky; top: 20px; border: 1px solid #e6e6e6; border-radius: 14px; background: #fff; padding: 20px; }
.map-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding-bottom: 16px; border-bottom: 1px solid #eee; }
.map-total { color: #888; font-size: 11px; font-variant-numeric: tabular-nums; }
.paragraph-map { padding-top: 10px; }
.map-item { position: relative; display: flex; gap: 14px; min-height: 58px; padding: 8px 0 12px; }
.map-item:not(:last-of-type)::after { content: ''; position: absolute; left: 5px; top: 23px; bottom: -8px; width: 1px; background: #dedede; }
.map-node { position: relative; z-index: 1; width: 11px; height: 11px; margin-top: 4px; border: 2px solid #111; border-radius: 999px; background: #fff; flex: 0 0 auto; }
.map-item.saved .map-node { background: #111; }
.map-item.draft .map-node { border-style: dashed; }
.map-copy { display: flex; flex-direction: column; gap: 4px; }
.map-copy strong { font-size: 13px; }
.map-copy span { color: #888; font-size: 11px; line-height: 1.35; }
.map-empty { padding: 28px 2px 12px; color: #aaa; font-size: 12px; text-align: center; }
@media (max-width: 900px) {
  .paragraph-builder-grid { grid-template-columns: 1fr; }
  .paragraph-map-panel { position: static; order: -1; }
  .paragraph-map { display: flex; flex-wrap: wrap; gap: 8px 20px; }
  .map-item { min-height: auto; padding: 5px 0; }
  .map-item::after { display: none !important; }
}
@media (max-width: 640px) {
  .paragraph-work-panel { padding: 18px; }
  .paragraph-welcome { min-height: 300px; }
  .paragraph-composer-head { align-items: flex-start; flex-direction: column; }
  .paragraph-save-actions { flex-direction: column; }
  .paragraph-save-actions .button-link { width: 100%; }
}

/* Chapter > Paragraph > Sentence hierarchy */
.thesis-tree-shell { width: min(1460px, calc(100% - 36px)); }
.tree-page-head { align-items: flex-start; }
.tree-head-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; justify-content: flex-end; }
.tree-project-delete { padding: 10px 0; }
.tree-stats strong { color: #111; font-weight: 700; }
.thesis-tree-grid { display: grid; grid-template-columns: minmax(245px, .72fr) minmax(520px, 1.8fr) 205px; gap: 18px; align-items: start; }
.tree-input-panel, .tree-content-panel, .tree-map-panel { border: 1px solid #e7e7e7; border-radius: 14px; background: #fff; }
.tree-input-panel { position: sticky; top: 18px; padding: 20px; }
.tree-input-panel h2 { margin: 6px 0 18px; font-size: 23px; letter-spacing: -.025em; }
.structure-add-actions { display: grid; gap: 9px; }
.button-link.full { width: 100%; }
.add-paragraph-form { display: grid; gap: 8px; }
.add-paragraph-form select { width: 100%; height: 40px; padding: 0 10px; border: 1px solid #dcdcdc; border-radius: 8px; background: #fff; color: #111; outline: none; }
.composer-divider { height: 1px; background: #ececec; margin: 20px 0; }
.composer-context { font-size: 12px; font-weight: 750; letter-spacing: .04em; }
.input-help { margin: 7px 0 12px; color: #818181; font-size: 12px; line-height: 1.5; }
.tree-textarea { min-height: 230px; resize: vertical; }
.parse-tree-btn { margin-top: 9px; }
.draft-meta { display: flex; justify-content: space-between; gap: 10px; margin-top: 10px; color: #777; font-size: 11px; }
.tree-preview { margin-top: 16px; border-top: 1px solid #eee; }
.tree-preview-row { display: grid; grid-template-columns: 34px 1fr; gap: 8px; padding: 10px 0; border-bottom: 1px solid #f0f0f0; }
.tree-preview-row span { color: #777; font-size: 11px; font-weight: 700; padding-top: 2px; }
.tree-preview-row p { margin: 0; font-size: 12px; line-height: 1.55; color: #242424; }
.vertical-save-actions { display: grid; gap: 8px; }
.input-empty-note { margin-top: 18px; padding: 18px 12px; border: 1px dashed #dedede; border-radius: 9px; color: #999; text-align: center; font-size: 12px; }

.tree-content-panel { min-width: 0; overflow: hidden; }
.tree-content-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; padding: 20px 22px; border-bottom: 1px solid #ededed; }
.tree-content-head h2 { margin: 5px 0 0; font-size: 21px; letter-spacing: -.02em; }
.tree-content-total { color: #8d8d8d; font-size: 11px; white-space: nowrap; }
.chapter-tree-list { padding: 12px 18px 24px; }
.chapter-block { margin-top: 12px; border: 1px solid #dfdfdf; border-radius: 12px; overflow: hidden; }
.chapter-block:first-child { margin-top: 0; }
.chapter-block-head, .paragraph-tree-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.chapter-block-head { padding: 14px 15px; background: #fafafa; border-bottom: 1px solid #e9e9e9; }
.chapter-block-head > div:first-child, .paragraph-tree-head > div:first-child { display: flex; align-items: baseline; gap: 9px; min-width: 0; }
.chapter-block-head strong { font-size: 14px; }
.chapter-block-head small, .paragraph-tree-head small { color: #969696; font-size: 10px; white-space: nowrap; }
.tree-code { display: inline-flex; min-width: 30px; color: #777; font-size: 10px; font-weight: 800; letter-spacing: .04em; }
.tree-delete-btn { border: 0; padding: 2px 0; background: transparent; color: #a05454; font-size: 10px; cursor: pointer; }
.paragraph-tree-block { margin: 12px; border-left: 2px solid #e6e6e6; padding-left: 12px; }
.paragraph-tree-head { min-height: 36px; padding: 2px 0 9px; border-bottom: 1px solid #efefef; }
.paragraph-tree-head strong { font-size: 12px; }
.paragraph-tree-actions { display: flex; align-items: center; gap: 10px; }
.tiny-link { color: #666; font-size: 10px; text-decoration: underline; text-underline-offset: 2px; }
.empty-paragraph-row, .empty-sentence-line { padding: 12px 14px; color: #aaa; font-size: 11px; }
.sentence-tree-lines { padding-top: 2px; }
.sentence-tree-line { display: grid; grid-template-columns: 34px minmax(0,1fr) auto; gap: 9px; align-items: start; padding: 10px 0; border-bottom: 1px solid #f2f2f2; }
.sentence-tree-line:last-child { border-bottom: 0; }
.sentence-tree-code { color: #8e8e8e; font-size: 10px; font-weight: 800; padding-top: 3px; }
.sentence-tree-line p { margin: 0; font-size: 13px; line-height: 1.58; overflow-wrap: anywhere; }
.sentence-delete { opacity: .72; }

.tree-map-panel { position: sticky; top: 18px; padding: 15px; }
.compact-map-head { padding-bottom: 11px; }
.chapter-map-tree { padding-top: 9px; }
.chapter-map-group { position: relative; padding: 6px 0 8px; }
.chapter-map-title { display: flex; align-items: center; gap: 7px; min-height: 24px; }
.chapter-map-title > span { width: 8px; height: 8px; border-radius: 999px; background: #111; flex: 0 0 auto; }
.chapter-map-title strong { font-size: 11px; }
.paragraph-map-row { position: relative; margin-left: 4px; padding: 5px 0 5px 14px; display: flex; justify-content: space-between; gap: 10px; color: #555; font-size: 10px; border-left: 1px solid #dedede; }
.paragraph-map-row::before { content: ''; position: absolute; left: -1px; top: 50%; width: 8px; border-top: 1px solid #dedede; }
.paragraph-map-row small { color: #999; font-size: 9px; }
.paragraph-map-row:hover { color: #111; }

.project-card-with-actions { padding: 0; overflow: hidden; position: relative; }
.project-card-with-actions:hover { transform: translateY(-1px); }
.project-card-main { display: block; padding: 22px 22px 15px; }
.project-card-delete { padding: 0 22px 16px; display: flex; justify-content: flex-end; }
.project-multi-stats { display: flex; gap: 22px; flex-wrap: wrap; }
.project-multi-stats span { display: inline-flex; align-items: baseline; gap: 3px; }
.project-multi-stats strong { margin-right: 0; }

.editor-tree-content .paragraph-tree-block { padding-bottom: 8px; }
.tree-editor-sentence { margin: 9px 0 0 34px; border-radius: 9px; padding: 12px; }
.tree-editor-sentence .editor-sentence-meta { margin-bottom: 8px; }
.tree-editor-sentence .sentence-edit-textarea { font-size: 13px; line-height: 1.55; }

@media (max-width: 1120px) {
  .thesis-tree-grid { grid-template-columns: minmax(235px, .72fr) minmax(0, 1.65fr); }
  .tree-map-panel { grid-column: 1 / -1; position: static; }
  .chapter-map-tree { display: flex; flex-wrap: wrap; gap: 8px 24px; }
  .chapter-map-group { min-width: 150px; }
}
@media (max-width: 820px) {
  .thesis-tree-grid { grid-template-columns: 1fr; }
  .tree-input-panel, .tree-map-panel { position: static; }
  .tree-map-panel { grid-column: auto; }
  .tree-content-panel { order: 2; }
  .tree-map-panel { order: 3; }
  .tree-head-actions { justify-content: flex-start; }
}
@media (max-width: 560px) {
  .thesis-tree-shell { width: min(100% - 22px, 1460px); }
  .tree-content-head, .chapter-block-head, .paragraph-tree-head { align-items: flex-start; flex-direction: column; }
  .sentence-tree-line { grid-template-columns: 28px minmax(0,1fr); }
  .sentence-tree-line form { grid-column: 2; }
  .tree-editor-sentence { margin-left: 12px; }
}

/* v7 — source hierarchy + loss-resistant rewrite workspace */
.source-v2-grid { grid-template-columns: minmax(255px,.76fr) minmax(560px,1.9fr) 190px; }
.subchapter-tree-block { margin: 12px; border-left: 2px solid #d8d8d8; padding-left: 12px; }
.subchapter-tree-head { display:flex; align-items:center; justify-content:space-between; gap:12px; padding:7px 0 10px; border-bottom:1px solid #ededed; }
.subchapter-tree-head > div { display:flex; align-items:baseline; gap:9px; }
.subchapter-tree-head strong { font-size:13px; }
.subchapter-tree-head small { color:#969696; font-size:10px; }
.source-edit-line { grid-template-columns:34px minmax(0,1fr) auto; }
.source-sentence-form { display:grid; grid-template-columns:minmax(0,1fr) auto; gap:8px; align-items:start; }
.source-sentence-text { width:100%; min-height:58px; resize:vertical; border:1px solid transparent; border-radius:7px; background:#fafafa; padding:8px 9px; color:#222; font:inherit; font-size:12.5px; line-height:1.55; }
.source-sentence-text:focus { border-color:#d4d4d4; background:#fff; outline:none; }
.source-map-sub { margin:2px 0 5px 4px; border-left:1px solid #d9d9d9; padding-left:10px; }
.source-map-sub > a:first-child { display:flex; align-items:center; justify-content:space-between; gap:8px; padding:4px 0; color:#444; font-size:10px; }
.source-map-sub > a:first-child small { color:#999; font-size:9px; }
.chapter-map-title small { margin-left:auto; color:#999; font-size:9px; }

.writer-shell { width:min(1580px,calc(100% - 34px)); margin:0 auto; padding:28px 0 56px; }
.writer-page-head { display:flex; align-items:flex-start; justify-content:space-between; gap:24px; margin-bottom:20px; }
.writer-page-head h1 { margin:5px 0 0; font-size:30px; letter-spacing:-.035em; }
.writer-head-actions { display:flex; align-items:center; gap:14px; }
.overall-progress { min-width:92px; text-align:right; }
.overall-progress strong { display:block; font-size:25px; line-height:1; font-variant-numeric:tabular-nums; }
.overall-progress span { color:#8a8a8a; font-size:10px; }
.progress-board { margin-bottom:18px; padding:17px 18px 15px; border:1px solid #e4e4e4; border-radius:14px; background:#fff; }
.progress-board-head { display:flex; justify-content:space-between; align-items:flex-end; gap:20px; margin-bottom:14px; }
.progress-board-head strong { display:block; margin-top:4px; font-size:13px; }
.progress-board-head > span { color:#999; font-size:10px; }
.progress-level { display:grid; grid-template-columns:78px minmax(0,1fr); gap:9px; align-items:stretch; margin-top:7px; }
.progress-level-label { display:flex; align-items:center; color:#858585; font-size:9px; text-transform:uppercase; letter-spacing:.06em; }
.progress-segments { display:flex; min-width:0; gap:3px; height:34px; }
.progress-segment { position:relative; min-width:46px; overflow:hidden; border:1px solid #e4e4e4; border-radius:6px; background:#f7f7f7; }
.progress-segment i { position:absolute; inset:0 auto 0 0; background:#dfeee3; transition:width .25s ease; }
.progress-segment.complete i { background:#cae6d1; }
.progress-segment span { position:relative; z-index:1; display:flex; align-items:center; justify-content:center; height:100%; padding:0 6px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; color:#555; font-size:9px; }
.progress-segment b { color:#111; font-variant-numeric:tabular-nums; }
.paragraph-progress-row { height:28px; }
.paragraph-progress-row .progress-segment span { font-size:8px; }

.writer-grid { display:grid; grid-template-columns:245px minmax(390px,.95fr) minmax(440px,1.1fr); gap:16px; align-items:start; }
.writer-nav-panel,.writer-sentence-panel,.rewrite-panel { border:1px solid #e5e5e5; border-radius:14px; background:#fff; min-width:0; }
.writer-nav-panel { position:sticky; top:16px; padding:16px; max-height:calc(100vh - 32px); overflow:auto; }
.writer-breadcrumb { display:flex; align-items:center; gap:5px; min-height:30px; margin:7px 0 12px; padding:6px 8px; border-radius:7px; background:#f7f7f7; font-size:10px; }
.writer-breadcrumb button { border:0; padding:0; background:none; color:#555; cursor:pointer; font-weight:700; }
.writer-breadcrumb b { color:#111; }
.writer-tree-nav { display:grid; gap:5px; }
.writer-tree-btn { width:100%; display:flex; justify-content:space-between; align-items:center; gap:9px; border:0; border-radius:7px; background:transparent; padding:8px 9px; color:#555; cursor:pointer; text-align:left; font-size:11px; }
.writer-tree-btn:hover { background:#f5f5f5; color:#111; }
.writer-tree-btn.active { background:#111; color:#fff; }
.writer-tree-btn small { opacity:.65; font-size:9px; font-variant-numeric:tabular-nums; }
.writer-sub-list { display:none; margin-left:9px; padding-left:8px; border-left:1px solid #e2e2e2; }
.writer-nav-chapter.open > .writer-sub-list { display:block; }
.writer-paragraph-list { display:none; margin-left:9px; padding-left:8px; border-left:1px solid #e7e7e7; }
.writer-nav-sub.open > .writer-paragraph-list { display:block; }
.sub-btn { padding-top:7px; padding-bottom:7px; }
.paragraph-btn { padding-top:6px; padding-bottom:6px; font-size:10px; }
.paragraph-btn small b { color:inherit; }

.writer-sentence-panel { min-height:560px; overflow:hidden; }
.writer-panel-head { display:flex; justify-content:space-between; align-items:flex-start; gap:12px; padding:17px 18px 14px; border-bottom:1px solid #ededed; }
.writer-panel-head h2 { margin:4px 0 0; font-size:17px; }
.writer-panel-head > span { color:#888; font-size:10px; }
.sentence-rail { padding:8px; }
.sentence-rail-item { width:100%; display:grid; grid-template-columns:34px minmax(0,1fr); gap:8px; align-items:start; border:1px solid transparent; border-bottom-color:#f0f0f0; border-radius:8px; background:#fff; padding:10px 9px; color:#222; cursor:pointer; text-align:left; }
.sentence-rail-item:hover { background:#fafafa; }
.sentence-rail-item.active { border-color:#cfcfcf; background:#f9f9f9; }
.sentence-rail-item.completed { background:#f2f8f3; border-bottom-color:#e0ece2; }
.sentence-rail-item.completed.active { border-color:#b8d3bd; }
.sentence-status-mark { display:flex; align-items:center; justify-content:center; width:27px; min-height:27px; border-radius:999px; background:#efefef; color:#777; font-size:9px; font-weight:800; }
.sentence-rail-item.completed .sentence-status-mark { background:#cfe7d4; color:#245b30; }
.sentence-rail-copy { display:block; padding-top:3px; font-size:12px; line-height:1.5; }
.writer-empty { padding:34px 18px; color:#aaa; font-size:12px; text-align:center; }

.rewrite-panel { position:sticky; top:16px; padding:18px; min-height:560px; }
.rewrite-empty { padding:60px 12px; text-align:center; }
.rewrite-empty h2 { margin:7px 0 8px; font-size:21px; }
.rewrite-empty p { margin:0 auto; max-width:310px; color:#888; font-size:12px; line-height:1.6; }
.rewrite-context { margin-bottom:11px; color:#777; font-size:10px; font-weight:750; letter-spacing:.05em; }
.original-sentence-card { padding:14px; border-radius:10px; background:#f7f7f7; border:1px solid #ededed; }
.original-sentence-card p { margin:7px 0 0; font-size:13px; line-height:1.62; }
.rewrite-field { margin-top:18px; }
.rewrite-label-row { display:flex; justify-content:space-between; align-items:center; gap:12px; margin-bottom:7px; }
.rewrite-label-row label { font-size:12px; font-weight:750; }
#autosaveStatus { color:#888; font-size:9px; }
#autosaveStatus.saved { color:#4b7654; }
#autosaveStatus.saving { color:#7b6d3e; }
#autosaveStatus.warn,#autosaveStatus.error { color:#9a5b46; }
#rewriteText { width:100%; min-height:235px; resize:vertical; border:1px solid #d9d9d9; border-radius:10px; padding:13px 14px; outline:none; background:#fff; color:#111; font:inherit; font-size:14px; line-height:1.65; }
#rewriteText:focus { border-color:#a9a9a9; box-shadow:0 0 0 3px rgba(0,0,0,.025); }
#rewriteText.approved { border-color:#b9d5bf; background:#fbfefb; }
.rewrite-actions { display:flex; flex-wrap:wrap; gap:8px; margin-top:11px; }
.approve-btn { margin-left:auto; }
.reopen-btn { margin-left:auto; }
.rewrite-saved-meta { margin-top:9px; min-height:14px; color:#999; font-size:9px; }

@media(max-width:1180px){.source-v2-grid{grid-template-columns:245px minmax(0,1fr)}.source-v2-grid .tree-map-panel{grid-column:1/-1}.writer-grid{grid-template-columns:220px minmax(0,1fr)}.rewrite-panel{grid-column:1/-1;position:static;min-height:0}.writer-nav-panel{top:10px}.progress-level{grid-template-columns:68px minmax(0,1fr)}}
@media(max-width:780px){.writer-shell{width:min(100% - 20px,1580px)}.writer-page-head,.progress-board-head{flex-direction:column;align-items:flex-start}.writer-head-actions{width:100%;justify-content:space-between}.writer-grid{grid-template-columns:1fr}.writer-nav-panel{position:static;max-height:none}.progress-level{grid-template-columns:1fr}.progress-segments{overflow-x:auto}.progress-segment{min-width:70px}.source-v2-grid{grid-template-columns:1fr}.source-edit-line{grid-template-columns:28px minmax(0,1fr)}.source-edit-line>form:last-child{grid-column:2}.source-sentence-form{grid-template-columns:1fr}.source-sentence-form .mini-btn{justify-self:start}}
.source-sentence-side { display:flex; align-items:flex-start; gap:8px; }
.source-add-after { position:relative; }
.source-add-after summary { list-style:none; width:22px; height:22px; display:flex; align-items:center; justify-content:center; border:1px solid #ddd; border-radius:6px; color:#666; cursor:pointer; font-size:14px; }
.source-add-after summary::-webkit-details-marker { display:none; }
.source-add-after form { position:absolute; z-index:20; right:0; top:27px; width:280px; padding:10px; border:1px solid #ddd; border-radius:9px; background:#fff; box-shadow:0 8px 24px rgba(0,0,0,.08); }
.source-add-after textarea { width:100%; min-height:78px; resize:vertical; border:1px solid #ddd; border-radius:7px; padding:8px; margin-bottom:7px; font:inherit; font-size:11px; }

/* v8 — shared app navigation + JSON transfer + dual-text writer rail */
.app-topbar { justify-content: space-between; gap: 22px; min-height: 68px; }
.app-nav-wrap { display:flex; align-items:center; min-width:0; gap:24px; }
.app-brand { font-size:15px; font-weight:800; letter-spacing:-.02em; white-space:nowrap; }
.app-nav { display:flex; align-items:center; gap:4px; min-width:0; }
.app-nav-link { display:inline-flex; align-items:center; min-height:34px; padding:0 10px; border-radius:7px; color:#777; font-size:12px; white-space:nowrap; }
.app-nav-link:hover { background:#f6f6f6; color:#111; }
.app-nav-link.active { background:#111; color:#fff; }
.topbar-right { display:flex; align-items:center; gap:24px; flex:0 0 auto; }

.form-intro { margin:-16px 0 26px; color:#777; font-size:13px; line-height:1.6; }
.create-project-card { max-width:680px; }
.create-mode-switch { display:grid; grid-template-columns:1fr 1fr; gap:6px; margin:0 0 24px; padding:5px; border:1px solid #e4e4e4; border-radius:10px; background:#fafafa; }
.create-mode-btn { min-height:39px; border:0; border-radius:7px; background:transparent; color:#777; cursor:pointer; font-size:13px; font-weight:700; }
.create-mode-btn.active { background:#111; color:#fff; }
.field-help { display:block; margin-top:6px; color:#999; font-size:10px; line-height:1.45; }
.field textarea.json-input, .json-input { width:100%; min-height:230px; resize:vertical; padding:12px 13px; border:1px solid #d9d9d9; border-radius:8px; background:#fff; color:#111; outline:none; font:12px/1.55 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace; }
.json-input:focus { border-color:#888; }
.import-or { position:relative; display:flex; justify-content:center; margin:18px 0; color:#aaa; font-size:10px; text-transform:uppercase; letter-spacing:.08em; }
.import-or::before { content:''; position:absolute; left:0; right:0; top:50%; border-top:1px solid #eee; }
.import-or span { position:relative; z-index:1; padding:0 10px; background:#fff; }

.transfer-shell { width:min(1320px,calc(100% - 36px)); margin:0 auto; padding:38px 0 70px; }
.transfer-head { display:flex; justify-content:space-between; align-items:flex-end; gap:24px; margin-bottom:24px; }
.transfer-head h1 { margin:6px 0 8px; font-size:36px; letter-spacing:-.035em; }
.transfer-head p { max-width:760px; margin:0; color:#777; font-size:13px; line-height:1.6; }
.transfer-project-context { display:flex; flex-direction:column; align-items:flex-end; gap:4px; min-width:180px; }
.transfer-project-context span { color:#999; font-size:10px; text-transform:uppercase; letter-spacing:.08em; }
.transfer-project-context strong { font-size:14px; }
.transfer-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:18px; align-items:start; }
.transfer-card { min-width:0; padding:20px; border:1px solid #e4e4e4; border-radius:14px; background:#fff; }
.transfer-card.schema-card { grid-column:1/-1; }
.transfer-card-head { display:flex; justify-content:space-between; align-items:flex-start; gap:14px; }
.transfer-card h2 { margin:5px 0 8px; font-size:20px; letter-spacing:-.02em; }
.transfer-card > p, .transfer-card-head + p { margin:0 0 16px; color:#777; font-size:12px; line-height:1.55; }
.json-output { width:100%; min-height:390px; resize:vertical; padding:14px; border:1px solid #e0e0e0; border-radius:9px; background:#fafafa; color:#222; outline:none; font:11px/1.55 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace; white-space:pre; }
.template-output { min-height:360px; margin-top:14px; }
.copy-row { display:flex; align-items:center; gap:10px; margin-top:10px; }
.copy-row span { color:#5e7f64; font-size:10px; }
.schema-rules { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:7px 22px; padding:13px 14px; border-radius:9px; background:#fafafa; }
.schema-rules p { margin:0; color:#666; font-size:11px; line-height:1.5; }
.schema-rules code { padding:2px 4px; border-radius:4px; background:#ececec; color:#222; }

.sentence-rail-item { grid-template-columns:34px minmax(0,1fr); }
.sentence-rail-stack { display:grid; gap:8px; min-width:0; }
.sentence-rail-source,.sentence-rail-rewrite { display:grid; gap:3px; min-width:0; }
.sentence-rail-source small,.sentence-rail-rewrite small { color:#999; font-size:8px; font-weight:800; text-transform:uppercase; letter-spacing:.07em; }
.sentence-rail-source > span:last-child { font-size:12px; line-height:1.5; color:#222; }
.sentence-rail-rewrite { padding-top:7px; border-top:1px dashed #e4e4e4; }
.sentence-rail-rewrite > span:last-child { font-size:11px; line-height:1.5; color:#111; font-weight:700; }
.sentence-rail-rewrite.is-empty > span:last-child { color:#aaa; font-style:italic; }
.sentence-rail-item.completed .sentence-rail-rewrite > span:last-child { color:#111; font-weight:700; }

@media(max-width:980px){
  .app-topbar { align-items:flex-start; min-height:auto; padding-top:12px; padding-bottom:12px; }
  .app-nav-wrap { align-items:flex-start; flex-direction:column; gap:8px; }
  .app-nav { flex-wrap:wrap; }
  .topbar-right { padding-top:1px; }
  .transfer-grid { grid-template-columns:1fr; }
  .transfer-card.schema-card { grid-column:auto; }
}
@media(max-width:680px){
  .app-topbar { flex-direction:column; gap:10px; }
  .topbar-right { width:100%; justify-content:space-between; }
  .app-nav-link { padding:0 7px; font-size:11px; }
  .transfer-shell { width:min(100% - 22px,1320px); padding-top:24px; }
  .transfer-head { flex-direction:column; align-items:flex-start; }
  .transfer-project-context { align-items:flex-start; }
  .schema-rules { grid-template-columns:1fr; }
}


/* v9 — compact export summary + stronger writing navigation/progress */
.export-summary-grid { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:9px; margin:15px 0 13px; }
.export-summary-stat { padding:13px 12px; border:1px solid #dfe6ef; border-radius:10px; background:#f8fbff; }
.export-summary-stat span { display:block; color:#718096; font-size:9px; font-weight:800; text-transform:uppercase; letter-spacing:.06em; }
.export-summary-stat strong { display:block; margin-top:5px; color:#172033; font-size:22px; font-variant-numeric:tabular-nums; }
.export-completion-summary { display:grid; gap:12px; margin:8px 0 4px; padding:14px; border:1px solid #e1e7ef; border-radius:11px; background:#fbfcfe; }
.export-progress-line > div:first-child { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:6px; color:#5f6b7d; font-size:10px; }
.export-progress-line b { color:#26364e; font-variant-numeric:tabular-nums; }
.export-progress-track { height:8px; overflow:hidden; border-radius:999px; background:#e8edf5; }
.export-progress-track i { display:block; height:100%; border-radius:inherit; background:#4f76c7; }
.export-progress-line.approved .export-progress-track i { background:#4f76c7; opacity:.68; }

.writer-nav-panel { border-color:#dbe5f2; background:#f8fbff; box-shadow:0 7px 24px rgba(44,76,120,.055); }
.writer-breadcrumb { background:#eef4ff; color:#35527f; border:1px solid #dbe7fb; }
.writer-breadcrumb button { color:#315b9a; }
.writer-sub-list { border-left-color:#cbd9f1; }
.writer-paragraph-list { border-left-color:#d8cff0; }
.writer-tree-btn { border:1px solid transparent; font-weight:700; transition:background .16s ease,border-color .16s ease,color .16s ease,transform .16s ease; }
.writer-tree-btn:hover { transform:translateX(1px); }
.chapter-btn { background:#edf4ff; border-color:#d9e7ff; color:#315b96; }
.chapter-btn:hover { background:#e2edff; color:#244a80; }
.chapter-btn.active { background:#3f6fb5; border-color:#3f6fb5; color:#fff; }
.sub-btn { background:#f4effd; border-color:#e7dcfa; color:#654a91; }
.sub-btn:hover { background:#ece3fa; color:#563a84; }
.sub-btn.active { background:#7558a6; border-color:#7558a6; color:#fff; }
.paragraph-btn { background:#edf8f6; border-color:#d9eee9; color:#376b62; }
.paragraph-btn:hover { background:#e2f3ef; color:#285e55; }
.paragraph-btn.active { background:#3f7e73; border-color:#3f7e73; color:#fff; }
.writer-tree-btn small { opacity:.82; }

.progress-board { border-color:#cfdced; background:#f7faff; box-shadow:0 8px 26px rgba(42,72,113,.07); }
.progress-board-head .metric-label { color:#486b9e; }
.progress-board-head strong { color:#1f3553; }
.progress-level-label { color:#4f6789; font-weight:850; }
.progress-segment { border-color:#cdd9e8; background:#e9eff7; box-shadow:inset 0 0 0 1px rgba(255,255,255,.45); }
.progress-segment i,
.progress-segment.complete i { background:#4f76c7; transition:width .28s ease; }
.progress-segment span { color:#24344c; font-weight:750; text-shadow:0 1px 0 rgba(255,255,255,.55); }
.progress-segment b { color:#17263d; }
.overall-progress strong { color:#315f9f; }
.overall-progress small { display:block; margin-top:4px; color:#6e7e94; font-size:9px; font-weight:750; }

.sentence-rail-rewrite > span:last-child,
.rewrite-preview-text { font-weight:800; color:#365f45; }
.sentence-rail-rewrite.is-empty > span:last-child { font-weight:500; }
.sentence-rail-item.completed .sentence-rail-rewrite > span:last-child { font-weight:850; }

@media(max-width:720px){
  .export-summary-grid{grid-template-columns:repeat(2,minmax(0,1fr));}
}


/* v10 — writing-card state: written = light blue, unwritten = near-white */
.sentence-rail-item,
.sentence-rail-item.completed {
  background: #fcfcfd;
  border-bottom-color: #f1f1f3;
}
.sentence-rail-item:hover,
.sentence-rail-item.completed:hover {
  background: #f7f9fc;
}
.sentence-rail-item.written,
.sentence-rail-item.written.completed {
  background: #eef6ff;
  border-bottom-color: #dceafb;
}
.sentence-rail-item.written:hover,
.sentence-rail-item.written.completed:hover {
  background: #e8f3ff;
}
.sentence-rail-item.active,
.sentence-rail-item.completed.active {
  border-color: #cbd5e1;
  background: #f6f8fb;
}
.sentence-rail-item.written.active,
.sentence-rail-item.written.completed.active {
  border-color: #a9c8ea;
  background: #e4f1ff;
}
.sentence-rail-rewrite > span:last-child,
.rewrite-preview-text,
.sentence-rail-item.completed .sentence-rail-rewrite > span:last-child {
  color: #111 !important;
  font-weight: 800 !important;
}
.sentence-rail-rewrite.is-empty > span:last-child,
.sentence-rail-rewrite.is-empty .rewrite-preview-text {
  color: #aaa !important;
  font-weight: 500 !important;
  font-style: italic;
}
#rewriteText.approved {
  border-color: #c8d8e8;
  background: #f7fbff;
}
