:root {
  color-scheme: light;
  --ink: #10213d;
  --ink-soft: #52627a;
  --ink-faint: #71819a;
  --paper: #f5f8fc;
  --surface: #ffffff;
  --surface-blue: #edf4ff;
  --line: #d5e0ef;
  --line-strong: #bdcde2;
  --blue: #1e5ed6;
  --blue-deep: #1746a4;
  --cyan: #0b8994;
  --green: #087c68;
  --amber: #a95c07;
  --red: #b4233a;
  --radius: 8px;
  --shadow: 0 14px 38px rgba(32, 61, 107, 0.09);
  --display: "Sora", "Avenir Next", sans-serif;
  --body: "Manrope", "Avenir Next", sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  color: var(--ink);
  background-color: var(--paper);
  background-image: linear-gradient(rgba(93, 121, 158, 0.07) 1px, transparent 1px), linear-gradient(90deg, rgba(93, 121, 158, 0.07) 1px, transparent 1px);
  background-size: 34px 34px;
  font-family: var(--body);
  text-rendering: optimizeLegibility;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.6;
}

[hidden] {
  display: none !important;
}

.skip-link,
.sr-only {
  position: absolute;
}

.skip-link {
  top: -48px;
  left: 1rem;
  z-index: 10;
  padding: 0.7rem 0.9rem;
  border-radius: 6px;
  background: var(--ink);
  color: var(--surface);
}

.skip-link:focus {
  top: 1rem;
}

.sr-only {
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.support-shell {
  min-height: 100svh;
  padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
}

.support-hub {
  width: min(100%, 1040px);
  margin: 0 auto;
  display: grid;
  gap: 0.75rem;
}

.support-header,
.workspace-panel,
.status-banner,
.view-tabs {
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 94%, var(--surface-blue));
  box-shadow: var(--shadow);
}

.support-header {
  min-height: 78px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.8rem 1rem;
  border-radius: var(--radius);
}

.brand,
.header-actions,
.view-tabs,
.detail-heading,
.field-label,
.form-footer,
.ticket-topline,
.ticket-summary,
.ticket-meta,
.reply-form {
  display: flex;
  align-items: center;
}

.brand {
  gap: 0.75rem;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: var(--blue);
  color: var(--surface);
  font-family: var(--display);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.brand small,
.panel-label {
  display: block;
  margin: 0 0 0.15rem;
  color: var(--ink-faint);
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.brand strong {
  display: block;
  font-family: var(--display);
  font-size: 1.15rem;
  line-height: 1;
}

.header-actions {
  gap: 0.45rem;
}

.unread-button,
.back-link,
.view-tab,
.text-action,
.back-button,
.load-more-button {
  min-height: 44px;
  border: 0;
  border-radius: 6px;
  color: var(--ink-soft);
  background: transparent;
  font-size: 0.82rem;
  font-weight: 800;
  text-decoration: none;
}

.unread-button {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  padding: 0 0.7rem;
}

.unread-button:hover,
.back-link:hover,
.text-action:hover,
.back-button:hover {
  color: var(--blue-deep);
  background: var(--surface-blue);
}

.unread-button strong,
.view-tab span,
.ticket-unread {
  min-width: 20px;
  min-height: 20px;
  display: inline-grid;
  place-items: center;
  padding: 0 0.32rem;
  border-radius: 999px;
  background: var(--blue);
  color: var(--surface);
  font-size: 0.67rem;
  font-weight: 800;
}

.back-link {
  display: inline-flex;
  align-items: center;
  padding: 0 0.75rem;
}

.view-tabs {
  width: fit-content;
  gap: 0.22rem;
  padding: 0.22rem;
  border-radius: var(--radius);
}

.view-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0 0.85rem;
}

.view-tab.is-active {
  background: var(--ink);
  color: var(--surface);
}

.view-tab.is-active span {
  background: var(--surface);
  color: var(--blue-deep);
}

.status-banner {
  margin: 0;
  padding: 0.72rem 0.85rem;
  border-radius: var(--radius);
  font-size: 0.84rem;
  font-weight: 700;
  line-height: 1.5;
}

.status-banner[data-tone="success"] {
  border-color: color-mix(in srgb, var(--green) 30%, var(--line));
  color: var(--green);
}

.status-banner[data-tone="error"] {
  border-color: color-mix(in srgb, var(--red) 28%, var(--line));
  color: var(--red);
}

.status-banner[data-tone="pending"] {
  color: var(--blue-deep);
}

.workspace-panel {
  min-width: 0;
  padding: clamp(1rem, 3vw, 1.5rem);
  border-radius: var(--radius);
  animation: panel-in 180ms ease-out;
}

.panel-heading,
.detail-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.panel-heading {
  margin-bottom: 1.25rem;
}

h2,
p {
  margin-top: 0;
}

h2 {
  margin-bottom: 0;
  font-family: var(--display);
  font-size: clamp(1.2rem, 2.5vw, 1.55rem);
  letter-spacing: 0;
}

.identity-state {
  padding-top: 0.18rem;
  color: var(--ink-faint);
  font-size: 0.73rem;
  font-weight: 700;
}

.identity-state[data-state="connected"] {
  color: var(--green);
}

.identity-state[data-state="anonymous"] {
  color: var(--amber);
}

.composer-layout {
  display: grid;
  grid-template-columns: minmax(200px, 0.64fr) minmax(0, 1.36fr);
  gap: 1.25rem;
}

.issue-types {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.issue-types legend,
.field-label label,
.contact-field span {
  color: var(--ink-soft);
  font-size: 0.76rem;
  font-weight: 800;
}

.issue-types legend {
  margin-bottom: 0.65rem;
}

.topic-list {
  display: grid;
  gap: 0.45rem;
}

.topic-list label {
  position: relative;
}

.topic-list input {
  position: absolute;
  opacity: 0;
}

.topic-list span {
  min-height: 44px;
  display: flex;
  align-items: center;
  padding: 0 0.8rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink-soft);
  background: var(--surface);
  font-size: 0.83rem;
  font-weight: 800;
  cursor: pointer;
}

.topic-list input:checked + span {
  border-color: var(--blue);
  background: var(--surface-blue);
  color: var(--blue-deep);
}

.topic-list input:focus-visible + span,
button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--blue) 38%, transparent);
  outline-offset: 2px;
}

.form-fields {
  min-width: 0;
}

.field-label {
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.55rem;
}

.field-label span {
  color: var(--ink-faint);
  font-size: 0.7rem;
}

textarea,
input[type="text"] {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  outline: none;
}

textarea {
  min-height: 156px;
  padding: 0.8rem 0.9rem;
  resize: vertical;
  line-height: 1.55;
}

input[type="text"] {
  min-height: 44px;
  padding: 0 0.8rem;
}

textarea::placeholder,
input::placeholder {
  color: var(--ink-faint);
}

textarea:focus,
input[type="text"]:focus {
  border-color: var(--blue);
}

.form-footer {
  align-items: end;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.contact-field {
  min-width: 0;
  flex: 1;
  display: grid;
  gap: 0.4rem;
}

.primary-action {
  min-height: 44px;
  flex: 0 0 auto;
  border: 1px solid var(--blue);
  border-radius: 6px;
  padding: 0 1rem;
  background: var(--blue);
  color: var(--surface);
  font-size: 0.82rem;
  font-weight: 800;
}

.primary-action:hover {
  background: var(--blue-deep);
  border-color: var(--blue-deep);
}

.panel-note {
  margin: -0.55rem 0 1rem;
  color: var(--ink-soft);
  font-size: 0.83rem;
}

.ticket-list,
.message-list {
  display: grid;
  gap: 0.65rem;
}

.ticket-row {
  width: 100%;
  display: grid;
  gap: 0.5rem;
  padding: 0.86rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: inherit;
  text-align: left;
}

.ticket-row:hover {
  border-color: var(--blue);
}

.ticket-topline,
.ticket-summary {
  justify-content: space-between;
  gap: 0.8rem;
}

.ticket-number {
  min-width: 0;
  color: var(--ink);
  font-size: 0.8rem;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.ticket-status,
.ticket-source {
  display: inline-flex;
  align-items: center;
  min-height: 21px;
  border-radius: 999px;
  padding: 0 0.45rem;
  font-size: 0.65rem;
  font-weight: 800;
}

.ticket-status[data-status="open"] {
  color: var(--blue-deep);
  background: var(--surface-blue);
}

.ticket-status[data-status="pending"] {
  color: var(--amber);
  background: #fff5e5;
}

.ticket-status[data-status="resolved"],
.ticket-status[data-status="closed"] {
  color: var(--green);
  background: #e7f7f1;
}

.ticket-status[data-status="replied"] {
  color: var(--cyan);
  background: #e6f7f8;
}

.ticket-summary {
  color: var(--ink-soft);
  font-size: 0.8rem;
  line-height: 1.4;
}

.ticket-summary > span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ticket-summary time {
  flex: 0 0 auto;
  color: var(--ink-faint);
  font-size: 0.7rem;
}

.empty-state {
  margin: 0;
  padding: 1rem;
  border: 1px dashed var(--line-strong);
  border-radius: 6px;
  color: var(--ink-soft);
  font-size: 0.85rem;
}

.load-more-button {
  width: 100%;
  margin-top: 0.8rem;
  border: 1px solid var(--line-strong);
  background: var(--surface);
}

.load-more-button:hover {
  border-color: var(--blue);
  color: var(--blue-deep);
}

.detail-heading {
  justify-content: flex-start;
  margin-bottom: 0.75rem;
}

.back-button {
  padding: 0 0.65rem;
}

.ticket-meta {
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0 0 1rem 3.6rem;
}

.ticket-source {
  color: var(--ink-soft);
  background: var(--surface-blue);
}

.message {
  display: grid;
  gap: 0.28rem;
}

.message[data-sender="user"] {
  justify-items: end;
}

.message-meta {
  color: var(--ink-faint);
  font-size: 0.7rem;
  font-weight: 700;
}

.message-bubble {
  width: min(100%, 650px);
  padding: 0.72rem 0.82rem;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
  font-size: 0.84rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.message[data-sender="user"] .message-bubble {
  border-color: var(--blue);
  background: var(--blue);
  color: var(--surface);
}

.reply-form {
  gap: 0.65rem;
  margin-top: 1rem;
}

.reply-form input {
  flex: 1;
}

@keyframes panel-in {
  from {
    opacity: 0;
    transform: translateY(5px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 620px) {
  .support-shell {
    padding: 0.7rem;
  }

  .support-header {
    min-height: 72px;
    padding: 0.72rem;
  }

  .back-link {
    display: none;
  }

  .composer-layout {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

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

  .form-footer {
    display: grid;
    grid-template-columns: 1fr;
  }

  .primary-action {
    width: 100%;
  }

  .ticket-meta {
    margin-left: 0;
  }

  .reply-form {
    display: grid;
    grid-template-columns: 1fr;
  }
}

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