:root {
  color-scheme: dark;
  --bg: #0d1017;
  --panel: rgba(27, 21, 36, 0.78);
  --panel-solid: #18131f;
  --panel-solid-soft: #221a2c;
  --input-bg: rgba(255, 255, 255, 0.045);
  --line: rgba(10, 10, 14, 0.95);
  --line-soft: rgba(255, 255, 255, 0.14);
  --text: #f7f2fb;
  --text-soft: rgba(247, 242, 251, 0.7);
  --accent: #ffffff;
  --success: #44d27a;
  --danger: #c15769;
  --warning: #c69d41;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  --radius: 0px;
  --border-width: 2px;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: 'Courier New', Courier, monospace;
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
}

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

button {
  cursor: pointer;
}

.page {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  background-image: url('/static/background.png');
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  background-attachment: fixed;
}

.page-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(7, 9, 12, 0.5);
}

.public-layout,
.login-layout,
.admin-layout {
  position: relative;
  z-index: 1;
}

.login-layout {
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 16px;
}

.public-layout {
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px 16px;
}

.brand-block {
  margin-bottom: 14px;
}

.brand-logo {
  width: min(190px, 42vw);
  height: auto;
}

.public-panel {
  width: min(100%, 540px);
  border: var(--border-width) solid var(--line);
  padding: 22px;
  background: var(--panel);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
}

.panel-header {
  margin-bottom: 14px;
  text-align: center;
}

.panel-title {
  display: none;
}

.panel-subtitle {
  font-size: 13px;
  color: var(--text-soft);
  margin: 0;
  line-height: 1.45;
}

.stack-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.text-input,
.message-editor,
.note-input {
  width: 100%;
  border: var(--border-width) solid var(--line);
  background: var(--input-bg);
  color: var(--text);
  padding: 12px 14px;
  outline: none;
  font-size: 15px;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}

input::placeholder,
textarea::placeholder {
  color: rgba(247, 242, 251, 0.45);
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
[contenteditable='true']:focus-visible {
  border-color: rgba(255, 255, 255, 0.5);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.08);
}

#nicknameInput {
  text-align: center;
}

.message-editor {
  min-height: 190px;
  line-height: 1.4;
  overflow-y: auto;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.message-textarea {
  resize: vertical;
  height: 180px;
  min-height: 180px;
  white-space: pre-wrap;
}

.toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.toolbar-button {
  border: var(--border-width) solid var(--line);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  padding: 8px 12px;
  font-weight: bold;
  transition: background 0.2s, color 0.2s;
}

.toolbar-button:hover {
  background: rgba(255, 255, 255, 0.1);
}

.toolbar-button.is-active,
.toolbar-button[aria-pressed='true'] {
  background: #ffffff;
  color: #000000;
}

.toolbar-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  font-size: 12px;
  color: var(--text-soft);
}

.toolbar-state {
  font-weight: bold;
}

.toolbar-counter {
  white-space: nowrap;
}

.toolbar-help {
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-soft);
}

.preview-panel {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.preview-panel.is-empty {
  display: none;
}

.preview-label {
  font-size: 12px;
  letter-spacing: 1px;
  color: var(--text-soft);
}

.message-preview {
  min-height: 76px;
  max-height: 112px;
  border: var(--border-width) solid var(--line);
  background: rgba(255, 255, 255, 0.035);
  color: var(--text);
  padding: 10px 12px;
  line-height: 1.45;
  white-space: normal;
  overflow-y: auto;
}

.message-preview:empty::before {
  content: attr(data-placeholder);
  color: rgba(255, 255, 255, 0.35);
}

.message-preview p {
  margin: 0 0 10px;
}

.message-preview p:last-child {
  margin-bottom: 0;
}

.captcha-grid {
  display: flex;
  justify-content: center;
  min-height: 65px;
  margin: 6px 0 2px;
}

#turnstileWidget {
  max-width: 100%;
}

.captcha-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.captcha-field .field-label {
  font-size: 12px;
  text-transform: uppercase;
}

.primary-button {
  background: var(--line);
  color: #fff;
  border: var(--border-width) solid var(--line);
  padding: 14px;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 1px;
  transition: opacity 0.2s;
}

.primary-button:hover {
  opacity: 0.9;
}

.primary-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.status-box,
.thanks-box {
  margin-top: 10px;
  font-size: 13px;
  text-align: center;
}

.status-box:empty {
  display: none;
}

.status-info { color: var(--text-soft); }
.status-error { color: #ff5555; }
.status-success { color: #55ff55; }

.thanks-box {
  padding: 14px 16px;
  border: var(--border-width) solid var(--success);
  background: rgba(13, 17, 24, 0.94);
  line-height: 1.45;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
}

.hidden { display: none; }

.admin-layout {
  max-width: 1280px;
  margin: 0 auto;
  padding: 28px 20px 32px;
}

.admin-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  border: var(--border-width) solid var(--line);
  padding: 20px 24px;
  margin-bottom: 22px;
  background: var(--panel-solid);
  box-shadow: var(--shadow);
}

.admin-brand {
  display: flex;
  align-items: center;
  gap: 18px;
  min-width: 0;
}

.admin-logo {
  width: 108px;
  flex-shrink: 0;
}

.admin-brand-copy {
  min-width: 0;
}

.admin-title {
  margin: 4px 0 6px;
  font-size: 28px;
  line-height: 1.05;
}

.admin-subtitle {
  margin: 0;
  color: var(--text-soft);
  font-size: 13px;
  line-height: 1.4;
}

.admin-actions {
  display: flex;
  align-items: center;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 22px;
}

.messages-panel,
.settings-panel {
  border: var(--border-width) solid var(--line);
  padding: 22px;
  background: var(--panel-solid);
  box-shadow: var(--shadow);
}

.settings-panel {
  position: sticky;
  top: 20px;
  align-self: start;
}

.panel-header-left {
  text-align: left;
}

.messages-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0;
  color: #d6cadf;
  font-size: 12px;
  font-weight: bold;
  letter-spacing: 1.4px;
  text-transform: uppercase;
}

.filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.filter-button {
  border: 1px solid var(--line-soft);
  background: var(--panel-solid-soft);
  color: var(--text);
  padding: 7px 11px;
  font-size: 12px;
}

.filter-active {
  background: #f7f2fb;
  border-color: #f7f2fb;
  color: #140f18;
}

.messages-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: calc(100svh - 250px);
  min-height: 360px;
  overflow-y: auto;
  padding-right: 4px;
}

.message-card {
  border: 1px solid var(--line-soft);
  padding: 16px;
  background: #130f18;
}

.message-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--line-soft);
  padding-bottom: 10px;
}

.message-title {
  font-size: 16px;
  margin: 0;
}

.message-meta {
  font-size: 12px;
  color: #c9bdd4;
  margin: 6px 0 0;
  line-height: 1.45;
}

.message-badge {
  flex-shrink: 0;
  font-size: 10px;
  text-transform: uppercase;
  border: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, 0.06);
  padding: 4px 7px;
}

.message-body {
  font-size: 14px;
  margin: 10px 0 12px;
  padding: 12px;
  min-height: 68px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.035);
  white-space: pre-wrap;
  line-height: 1.55;
}

.message-delivery {
  margin: 0 0 12px;
  color: #d7ccd9;
}

.flag-row {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.flag-button {
  font-size: 10px;
  border: 1px solid var(--line-soft);
  background: var(--panel-solid-soft);
  color: var(--text);
  padding: 4px 7px;
}

.flag-selected {
  background: #f7f2fb;
  border-color: #f7f2fb;
  color: #140f18;
}

.note-wrap {
  margin-top: 15px;
}

.field-label {
  display: block;
  margin-bottom: 8px;
  color: #d7ccd9;
  font-size: 13px;
}

.note-input {
  min-height: 72px;
  resize: vertical;
}

.card-actions {
  margin-top: 12px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.ghost-button,
.danger-button {
  border: 1px solid var(--line-soft);
  background: var(--panel-solid-soft);
  color: var(--text);
  padding: 9px 12px;
  font-size: 12px;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.ghost-button:hover {
  background: rgba(255, 255, 255, 0.11);
}

.danger-button {
  background: rgba(193, 87, 105, 0.12);
  border-color: rgba(193, 87, 105, 0.5);
}

.danger-button:hover {
  background: rgba(193, 87, 105, 0.24);
}

.button-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 4px;
}

.settings-panel .text-input {
  background: #21192c;
}

.settings-panel .primary-button {
  background: #f7f2fb;
  border-color: #f7f2fb;
  color: #140f18;
}

.empty-state {
  padding: 18px;
  border: 1px dashed var(--line-soft);
  color: #d7ccd9;
  text-align: center;
}

.login-panel {
  width: min(100%, 400px);
}

.login-brand {
  text-align: center;
  margin-bottom: 18px;
}

.login-logo {
  width: 150px;
}

.page-public .brand-logo {
  width: min(168px, 42vw);
}

.page-public .thanks-box {
  display: none !important;
}

.page-admin .page-backdrop,
.page-admin-login .page-backdrop {
  background: rgba(7, 8, 12, 0.72);
}

.page-admin .public-panel,
.page-admin-login .public-panel {
  background: rgba(24, 19, 31, 0.92);
}

@media (max-width: 1100px) {
  .admin-grid {
    grid-template-columns: 1fr;
  }

  .settings-panel {
    position: static;
  }

  .messages-list {
    max-height: none;
    min-height: 0;
  }
}

@media (max-width: 600px) {
  .page {
    background-attachment: scroll;
    background-position: center top;
  }

  .public-layout,
  .login-layout {
    min-height: 100vh;
    min-height: 100svh;
    justify-content: flex-start;
    padding: 14px 12px 18px;
  }

  .page-public .brand-logo,
  .login-logo {
    width: min(132px, 36vw);
  }

  .public-panel,
  .messages-panel,
  .settings-panel {
    padding: 16px;
  }

  .panel-header {
    margin-bottom: 12px;
  }

  .stack-form {
    gap: 10px;
  }

  .toolbar {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .toolbar-button {
    padding: 10px 8px;
    text-align: center;
  }

  .toolbar-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .message-editor,
  .message-textarea {
    height: 146px;
    min-height: 146px;
  }

  .message-preview {
    min-height: 60px;
    max-height: 90px;
  }

  .toolbar-help,
  .preview-label,
  .toolbar-meta,
  .panel-subtitle {
    font-size: 11px;
  }

  .captcha-grid {
    margin: 2px 0 0;
  }

  .primary-button {
    padding: 13px;
  }

  .admin-layout {
    padding: 14px 12px 20px;
  }

  .admin-topbar,
  .messages-header,
  .message-card-header {
    flex-direction: column;
    align-items: stretch;
  }

  .admin-brand {
    align-items: flex-start;
    gap: 12px;
  }

  .admin-logo {
    width: 88px;
  }

  .admin-title {
    font-size: 22px;
  }

  .admin-actions,
  .card-actions {
    width: 100%;
  }

  .admin-actions .ghost-button,
  .card-actions button,
  .button-stack button {
    width: 100%;
  }

  .filters,
  .flag-row {
    gap: 6px;
  }

  .filter-button,
  .flag-button {
    flex: 1 1 calc(50% - 6px);
    text-align: center;
  }

}

@media (max-width: 380px) {
  #turnstileWidget {
    transform: scale(0.94);
    transform-origin: center top;
  }

  .captcha-grid {
    min-height: 58px;
  }
}
