:root {
  color-scheme: light dark;
  --bg: #f4f6f2;
  --surface: #fcfdfb;
  --surface-strong: #ffffff;
  --text: #18201e;
  --muted: #5e6b67;
  --line: #d8dedb;
  --accent: #176b5b;
  --accent-hover: #10594c;
  --accent-soft: #dcefe9;
  --danger: #a23932;
  --warning: #8a5b16;
  --shadow: 0 18px 50px rgba(30, 55, 48, 0.08);
  --radius: 14px;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121715;
    --surface: #18201d;
    --surface-strong: #1e2925;
    --text: #edf3f0;
    --muted: #a5b3ae;
    --line: #34413d;
    --accent: #6fc3aa;
    --accent-hover: #8ed2bd;
    --accent-soft: #203d35;
    --danger: #f09b92;
    --warning: #e4ba76;
    --shadow: 0 18px 50px rgba(0, 0, 0, 0.22);
  }
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
}

button,
input,
textarea {
  font: inherit;
}

button,
.file-button {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
.file-button:focus-within {
  outline: 3px solid color-mix(in srgb, var(--accent) 32%, transparent);
  outline-offset: 2px;
}

button:active,
.file-button:active {
  transform: translateY(1px);
}

[hidden] {
  display: none !important;
}

.login-view {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-box {
  width: min(100%, 390px);
  padding: 34px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.brand-mark {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--accent);
  color: var(--bg);
  font-size: 25px;
  font-weight: 800;
}

.brand-mark.small {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  font-size: 17px;
}

.login-box h1 {
  margin: 24px 0 8px;
  font-size: 30px;
  letter-spacing: -0.04em;
}

.login-box > p,
.composer-heading p,
.board-heading p {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.login-form {
  margin-top: 28px;
}

.login-form label,
.field-label,
.search-field span {
  display: block;
  margin-bottom: 8px;
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-strong);
  color: var(--text);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

input {
  min-height: 48px;
  padding: 0 14px;
}

textarea {
  min-height: 124px;
  padding: 14px;
  resize: vertical;
  line-height: 1.65;
}

input::placeholder,
textarea::placeholder {
  color: color-mix(in srgb, var(--muted) 82%, transparent);
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 12%, transparent);
}

.primary-button,
.secondary-button,
.filter-button,
.text-button {
  cursor: pointer;
  border: 0;
  transition: background-color 160ms ease, color 160ms ease, border-color 160ms ease, transform 80ms ease;
}

.primary-button {
  width: 100%;
  min-height: 50px;
  padding: 0 18px;
  border-radius: 10px;
  background: var(--accent);
  color: var(--bg);
  font-weight: 800;
}

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

.primary-button:disabled,
.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.login-form .primary-button {
  margin-top: 10px;
}

.form-error {
  min-height: 21px;
  margin: 7px 0 0;
  color: var(--danger);
  font-size: 14px;
  line-height: 1.5;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(14px);
}

.topbar-inner {
  width: min(100% - 32px, 920px);
  min-height: 66px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 800;
  text-decoration: none;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.role-label {
  color: var(--muted);
  font-size: 13px;
}

.text-button {
  padding: 8px 4px;
  background: transparent;
  color: var(--accent);
  font-weight: 700;
}

.page-shell {
  width: min(100% - 32px, 760px);
  margin: 0 auto;
  padding: 38px 0 80px;
}

.composer {
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.composer-heading {
  margin-bottom: 24px;
}

.composer h1,
.board h2 {
  margin: 0 0 7px;
  letter-spacing: -0.035em;
}

.composer h1 {
  font-size: clamp(26px, 6vw, 36px);
}

.board h2 {
  font-size: 25px;
}

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

.secondary-button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-strong);
  color: var(--text);
  font-weight: 700;
}

.secondary-button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.secondary-button.recording {
  border-color: var(--danger);
  color: var(--danger);
}

.attachment-preview {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

.attachment-preview img {
  display: block;
  width: min(100%, 260px);
  max-height: 190px;
  margin-top: 10px;
  border-radius: 8px;
  object-fit: contain;
}

.submit-button {
  margin-top: 2px;
}

.board {
  margin-top: 46px;
}

.board-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
}

.board-tools {
  margin: 22px 0;
  display: grid;
  gap: 14px;
}

.filters {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.filter-button {
  flex: 0 0 auto;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-weight: 700;
}

.filter-button.active {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--bg);
}

.system-note {
  margin: 0 0 16px;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  font-size: 14px;
}

.issues {
  display: grid;
  gap: 14px;
}

.issue {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.issue.mine {
  border-color: color-mix(in srgb, var(--accent) 62%, var(--line));
}

.issue-main {
  padding: 21px;
}

.issue-topline {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 11px;
  color: var(--muted);
  font-size: 13px;
}

.issue-number {
  color: var(--text);
  font-weight: 850;
  font-variant-numeric: tabular-nums;
}

.status-label,
.mine-label,
.urgency-label {
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
}

.urgency-label {
  color: var(--warning);
  background: color-mix(in srgb, var(--warning) 13%, transparent);
}

.issue h3 {
  margin: 0;
  font-size: 19px;
  line-height: 1.45;
}

.issue-summary {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.7;
  white-space: pre-wrap;
}

.area-line {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.source-details {
  margin-top: 13px;
}

.source-details summary {
  cursor: pointer;
  color: var(--accent);
  font-size: 14px;
  font-weight: 700;
}

.source-content {
  margin-top: 10px;
  padding: 12px;
  border-radius: 10px;
  background: var(--bg);
  color: var(--muted);
  line-height: 1.65;
  white-space: pre-wrap;
}

.issue-media {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.issue-media img {
  width: min(100%, 440px);
  max-height: 420px;
  border-radius: 10px;
  object-fit: contain;
  background: var(--bg);
}

.issue-media audio {
  width: min(100%, 420px);
}

.thread {
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 52%, var(--surface));
}

.messages {
  display: grid;
  gap: 11px;
  padding: 17px 21px;
}

.message {
  max-width: 88%;
}

.message.employee {
  justify-self: start;
}

.message.admin {
  justify-self: end;
}

.message.ai {
  justify-self: start;
}

.message-author {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
}

.message-body {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-strong);
  line-height: 1.6;
  white-space: pre-wrap;
}

.message.admin .message-body {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--bg);
}

.message.ai .message-body {
  background: var(--accent-soft);
}

.reply-area {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 9px;
  padding: 0 21px 18px;
}

.reply-area input {
  min-width: 0;
}

.reply-area button,
.status-actions button {
  width: auto;
  min-height: 46px;
}

.status-actions {
  display: flex;
  gap: 8px;
  padding: 0 21px 19px;
}

.status-actions .secondary-button {
  flex: 1;
}

.empty-state,
.loading-state {
  padding: 44px 24px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
  line-height: 1.7;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom));
  z-index: 20;
  width: max-content;
  max-width: calc(100% - 32px);
  transform: translateX(-50%);
  padding: 12px 16px;
  border-radius: 10px;
  background: var(--text);
  color: var(--bg);
  box-shadow: var(--shadow);
  font-weight: 700;
}

@media (min-width: 720px) {
  .board-tools {
    grid-template-columns: minmax(220px, 1fr) auto;
    align-items: end;
  }
}

@media (max-width: 560px) {
  .login-box {
    padding: 26px 22px;
  }

  .page-shell {
    width: min(100% - 20px, 760px);
    padding-top: 16px;
  }

  .composer {
    padding: 21px 16px;
  }

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

  .issue-main,
  .messages {
    padding-left: 16px;
    padding-right: 16px;
  }

  .reply-area {
    grid-template-columns: 1fr;
    padding-left: 16px;
    padding-right: 16px;
  }

  .status-actions {
    padding-left: 16px;
    padding-right: 16px;
  }

  .role-label {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
