:root {
  color-scheme: light;
  --bg: #eef1f4;
  --panel: #ffffff;
  --ink: #18212f;
  --muted: #687386;
  --line: #d5dbe3;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --warn: #b45309;
  --danger: #b91c1c;
}

* {
  box-sizing: border-box;
}

.hidden {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 "Segoe UI", Arial, sans-serif;
}

.loginOverlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: var(--bg);
}

.loginOverlay.hidden {
  display: none;
}

.loginBox {
  display: grid;
  gap: 14px;
  width: min(420px, 100%);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.loginBox p {
  color: var(--muted);
}

.loginBox label span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 54px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(8px);
}

.brandLine {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 18px;
  font-weight: 700;
  white-space: nowrap;
}

h2 {
  margin-bottom: 10px;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0;
  color: var(--muted);
}

h3 {
  font-size: 15px;
}

#subtitle {
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.actions {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding-right: 174px;
}

.sectionSwitch,
.langSwitch {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  background: #fff;
}

.sectionSwitch button,
.langSwitch button {
  border: 0;
  border-radius: 0;
}

.topRightControls {
  position: fixed;
  top: 10px;
  right: 10px;
  z-index: 400;
  display: flex;
  align-items: center;
  gap: 8px;
}

.globalLangSwitch {
  width: 112px;
  height: 36px;
  box-shadow: 0 8px 24px rgba(24, 33, 47, 0.16);
}

.globalLangSwitch button {
  width: 56px;
  min-height: 34px;
  padding: 0;
  font-weight: 700;
}

.sectionSwitch button.active,
.langSwitch button.active {
  background: var(--ink);
  color: #fff;
}

.accountBtn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 8px 24px rgba(24, 33, 47, 0.16);
  font-weight: 800;
  letter-spacing: 0;
}

.accountBtn:hover {
  border-color: var(--accent-dark);
  background: var(--accent-dark);
}

.accountBtn.hidden {
  display: none;
}

.saveState {
  min-width: 96px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: #fff;
  text-align: center;
  white-space: nowrap;
}

.saveState.good {
  border-color: #a7d8ce;
  color: var(--accent-dark);
  background: #effaf7;
}

.saveState.pending {
  border-color: #f0c779;
  color: var(--warn);
  background: #fff8eb;
}

.saveState.error {
  border-color: #efb4b4;
  color: var(--danger);
  background: #fff2f2;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 10px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

button:hover {
  border-color: #aeb8c5;
}

button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

button.primary:hover {
  background: var(--accent-dark);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

button.secondary {
  width: 100%;
  margin-top: 8px;
}

.layout {
  display: block;
  padding: 18px;
}

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

.toolbarMessage {
  width: min(1640px, calc(100% - 36px));
  min-height: 24px;
  margin: 10px auto 0;
}

.exportMenuWrap {
  position: relative;
}

.exportMenu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 50;
  display: grid;
  gap: 6px;
  width: 190px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 16px 38px rgba(24, 33, 47, 0.18);
}

.exportMenu.hidden {
  display: none;
}

.exportMenu button {
  width: 100%;
  text-align: left;
}

.sidebar {
  position: sticky;
  top: 82px;
  align-self: start;
  display: grid;
  gap: 12px;
  max-height: calc(100vh - 100px);
  overflow: auto;
}

.panel {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.panel a {
  display: block;
  margin: 8px 0;
  color: var(--accent-dark);
  text-decoration: none;
}

.panel a:hover {
  text-decoration: underline;
}

#searchInput,
.field input,
.cardHeader input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
}

#searchInput,
.field input,
.cardHeader input,
select {
  min-height: 36px;
  padding: 7px 9px;
}

textarea {
  resize: vertical;
  min-height: 76px;
  padding: 9px;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  color: var(--ink);
}

.check input,
.cardControls input {
  width: auto;
}

.stats {
  display: grid;
  gap: 6px;
  color: var(--muted);
}

.message {
  margin-top: 10px;
  color: var(--muted);
  word-break: break-word;
}

.message.error {
  color: var(--danger);
}

.message.good {
  color: var(--accent-dark);
}

.cards {
  display: grid;
  gap: 16px;
}

.emptyState {
  padding: 24px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
}

.card {
  display: grid;
  grid-template-columns: minmax(280px, 38%) minmax(0, 1fr);
  gap: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

body[data-role="client"] .sidebar,
body[data-role="client"] #exportBtn,
body[data-role="client"] #selectAllBtn,
body[data-role="client"] .exportMenuWrap,
body[data-role="client"] .refsField,
body[data-role="client"] .refsInput {
  display: none;
}

body[data-role="client"] .layout {
  display: block;
}

body[data-role="client"] .card {
  grid-template-columns: minmax(280px, 46%) minmax(0, 1fr);
}

body[data-role="client"] .titleInput,
body[data-role="client"] textarea {
  border-color: transparent;
  background: #f8fafc;
}

body[data-lang="ru"] .enField,
body[data-lang="ru"] .enChatField,
body[data-lang="en"] .ruField,
body[data-lang="en"] .ruChatField {
  display: none;
}

.clientCommentBox {
  margin-top: 16px;
  padding: 12px;
  border: 1px solid #b8d8d4;
  border-radius: 8px;
  background: #f0fdfa;
}

.clientCommentBox textarea {
  background: #fff;
  border-color: var(--line);
}

.clientCommentActions {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}

.imagePane {
  min-width: 0;
}

.selectCheck {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
}

.selectCheck input {
  width: auto;
}

.imageWrap {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 260px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  overflow: hidden;
}

.imageWrap.isMissing {
  min-height: 220px;
}

.imagePlaceholder {
  display: none;
  padding: 22px;
  color: var(--muted);
  text-align: center;
}

.imageWrap.isMissing .storyImage,
.imageWrap.isMissing .openImageBtn {
  display: none;
}

.imageWrap.isMissing .imagePlaceholder {
  display: block;
}

.openImageBtn {
  position: absolute;
  right: 10px;
  bottom: 10px;
  border-color: rgba(24, 33, 47, 0.35);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 6px 20px rgba(24, 33, 47, 0.16);
}

.storyImage {
  display: block;
  max-width: 100%;
  max-height: 520px;
  object-fit: contain;
  cursor: zoom-in;
}

.fileName {
  margin-top: 8px;
  color: var(--muted);
  word-break: break-word;
}

.markupSummary {
  display: grid;
  gap: 3px;
  margin-top: 7px;
  padding: 8px;
  border-left: 3px solid #0f766e;
  background: #f0fdfa;
  color: var(--ink);
  font-size: 13px;
}

.markupSummary small {
  color: var(--muted);
}

.originalRefsPreview {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.originalRefsPreview img {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
}

.editPane {
  min-width: 0;
}

.card.originalTextCard {
  grid-template-columns: minmax(280px, 1fr) minmax(220px, 360px);
}

.card.originalTextCard .commentThread,
.card.originalTextCard .openImageBtn,
.card.originalTextCard .markupSummary {
  display: none;
}

.card.originalTextCard .storyImage {
  max-height: 760px;
}

.card.originalTextCard .titleInput {
  background: #f8fafc;
}

.card.contactSheetCard {
  display: block;
  padding: 14px;
}

.card.contactSheetCard .selectCheck,
.card.contactSheetCard .openImageBtn,
.card.contactSheetCard .editPane,
.card.contactSheetCard .markupSummary {
  display: none;
}

.card.contactSheetCard .imagePane {
  display: grid;
  gap: 10px;
}

.card.contactSheetCard .imageWrap {
  min-height: 0;
}

.card.contactSheetCard .storyImage {
  display: block;
  width: 100%;
  max-height: none;
  border-radius: 6px;
}

.card.contactSheetCard .fileName {
  font-size: 14px;
  color: var(--ink);
}

.deadlineBadge {
  width: max-content;
  max-width: 100%;
  margin-top: 6px;
  padding: 4px 8px;
  border: 1px solid #f2d59f;
  border-radius: 6px;
  background: #fff7ed;
  color: #8a4b08;
  font-size: 12px;
  font-weight: 700;
}

.cardHeader {
  margin-bottom: 12px;
}

.titleField {
  margin-top: 0;
}

.titleInput {
  font-weight: 700;
}

.field {
  display: block;
  margin-top: 10px;
}

.field span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 13px;
}

.commentsHeader {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.statusInline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.statusInline span {
  display: inline;
}

.statusSelect {
  max-width: 220px;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 26px 4px 10px;
  background: #fff;
  color: var(--ink);
  font-size: 12px;
}

.statusSelect:disabled {
  opacity: 1;
  color: var(--muted);
  background: #f8fafc;
}

.comments {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  max-height: 360px;
  padding: 2px 4px 2px 0;
  overflow: auto;
}

.comment {
  width: min(84%, 620px);
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--ink);
  white-space: pre-wrap;
}

.comment.left {
  justify-self: start;
  border-color: #d7e2ef;
  background: #f8fafc;
}

.comment.right {
  justify-self: end;
  border-color: #b8d8d4;
  background: #f0fdfa;
}

.commentNotice {
  justify-self: stretch;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  padding: 6px 10px;
  border: 1px solid #dbe3ee;
  border-radius: 999px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}

.commentNotice::before,
.commentNotice::after {
  content: "";
  height: 1px;
  flex: 1 1 auto;
  background: var(--line);
}

.commentNotice span {
  flex: 0 1 auto;
  text-align: center;
}

.commentMeta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 5px;
  font-size: 12px;
  color: var(--muted);
}

.commentMeta strong {
  color: var(--ink);
}

.commentBody {
  color: var(--ink);
}

.commentTranslationFlag {
  margin-top: 6px;
  color: var(--warn);
  font-size: 12px;
}

.commentComposer {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.commentComposer textarea {
  min-height: 82px;
}

.commentComposer button {
  justify-self: end;
}

.imageModal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background: #101722;
  color: #f8fafc;
}

.imageModal.hidden {
  display: none;
}

.modalTopbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 16px;
  align-items: center;
  min-height: 52px;
  padding: 7px 140px 7px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(16, 23, 34, 0.98);
}

.modalTitleBlock h2 {
  margin: 0;
  font-size: 16px;
  text-transform: none;
  color: #fff;
}

.modalTitleBlock p {
  margin-top: 2px;
  color: #b8c2d2;
}

.modalActions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: nowrap;
  max-width: calc(100vw - 520px);
  overflow-x: auto;
  white-space: nowrap;
}

.modalActions button,
.compactControl {
  border-color: rgba(255, 255, 255, 0.16);
  background: #1c2635;
  color: #f8fafc;
}

.modalActions button {
  min-height: 34px;
  padding: 6px 9px;
}

.modalActions button:hover {
  border-color: rgba(255, 255, 255, 0.38);
}

.modalActions button.active,
.viewSwitch button.active {
  border-color: #5eead4;
  background: #0f766e;
  color: #fff;
}

.viewSwitch {
  display: inline-flex;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 6px;
}

.viewSwitch button {
  border: 0;
  border-radius: 0;
}

.compactControl {
  display: grid;
  grid-template-columns: auto auto;
  gap: 6px;
  align-items: center;
  min-height: 38px;
  padding: 4px 8px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 6px;
}

.compactControl span {
  color: #b8c2d2;
  font-size: 12px;
}

.compactControl input[type="color"] {
  width: 30px;
  height: 26px;
  min-height: 0;
  padding: 0;
}

.sizeControl input {
  width: 92px;
}

.modalLayout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  min-height: 0;
  overflow: hidden;
}

.imageStage {
  position: relative;
  display: block;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: #0b111b;
  cursor: crosshair;
}

.imageStage.panMode {
  cursor: grab;
}

.imageStage.isPanning {
  cursor: grabbing;
}

.modalImageFrame {
  position: absolute;
  left: 0;
  top: 0;
  width: 100px;
  height: 100px;
  transform-origin: 0 0;
  will-change: transform;
  line-height: 0;
  background: #fff;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  touch-action: none;
}

.modalImageFrame.before #drawingCanvas {
  opacity: 0;
  pointer-events: none;
}

#modalImage {
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  object-fit: fill;
  pointer-events: none;
  user-select: none;
}

#drawingCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
  z-index: 2;
}

.imageStage.panMode #drawingCanvas {
  cursor: grab;
}

.imageStage.isPanning #drawingCanvas {
  cursor: grabbing;
}

.inlineTextEditor {
  position: absolute;
  z-index: 3;
  min-width: 160px;
  min-height: 38px;
  padding: 6px 8px;
  border: 2px solid #5eead4;
  border-radius: 4px;
  outline: none;
  resize: both;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.92);
  color: #111827;
  line-height: 1.2;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.28);
}

.inlineTextEditor.hidden {
  display: none;
}

.revisionPanel {
  min-width: 0;
  padding: 14px;
  border-left: 1px solid rgba(255, 255, 255, 0.12);
  background: #151f2c;
  overflow: auto;
}

.revisionPanel h3 {
  margin-bottom: 8px;
}

.revisionPanel .field span,
#revisionHint {
  color: #b8c2d2;
}

.revisionPanel textarea {
  border-color: rgba(255, 255, 255, 0.16);
  background: #101722;
  color: #f8fafc;
}

.revisionMeta {
  min-height: 18px;
  margin-top: 8px;
  color: #b8c2d2;
  font-size: 12px;
}

.saveRevisionBtn {
  width: 100%;
  margin-top: 10px;
}

.revisionList {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.revisionItem {
  width: 100%;
  padding: 9px;
  text-align: left;
  border-color: rgba(255, 255, 255, 0.14);
  background: #1c2635;
  color: #f8fafc;
}

.revisionItem strong,
.revisionItem span {
  display: block;
}

.revisionItem span {
  margin-top: 2px;
  color: #b8c2d2;
  font-size: 12px;
}

@media (max-width: 980px) {
  .topbar,
  .brandLine,
  .layout,
  .card,
  .cardHeader,
  .commentTop,
  .modalTopbar,
  .modalLayout {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

  .actions,
  .modalTopbar {
    padding-right: 174px;
  }

  .brandLine {
    display: flex;
    flex-wrap: wrap;
  }

  .sidebar {
    position: static;
    max-height: none;
  }

  .layout {
    display: grid;
  }

  .modalLayout {
    grid-template-rows: minmax(0, 1fr) auto;
  }

  .modalActions {
    max-width: none;
    justify-content: flex-start;
  }

  .revisionPanel {
    max-height: 32vh;
    border-left: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
  }
}
