/* BufferCopy web client. Calm and compact, after GNOME's libadwaita:
   system fonts, light and dark through prefers-color-scheme, phone to
   desktop. Loaded from 'self' only (CSP §11.6); no inline styles anywhere. */

:root {
  color-scheme: light dark;
  --bg: #fafafb;
  --fg: rgb(0 0 6 / 0.82);
  --dim: rgb(0 0 6 / 0.58);
  --card: #ffffff;
  --card-border: rgb(0 0 6 / 0.09);
  --shade: rgb(0 0 6 / 0.07);
  --shade-hover: rgb(0 0 6 / 0.11);
  --shade-active: rgb(0 0 6 / 0.16);
  --header: #ebebed;
  --accent: #3584e4;
  --accent-hover: #4a90e8;
  --accent-text: #1c71d8;
  --on-accent: #ffffff;
  --destructive: #e01b24;
  --destructive-text: #c01c28;
  --success: #1b8553;
  --warning: #9c6e03;
  --focus: rgb(53 132 228 / 0.55);
  --radius: 12px;
  --radius-small: 6px;
  --shadow: 0 1px 3px rgb(0 0 6 / 0.08);
  font-family: "Adwaita Sans", Cantarell, system-ui, -apple-system, "Segoe UI", Ubuntu, "Noto Sans", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #222226;
    --fg: #ffffff;
    --dim: rgb(255 255 255 / 0.6);
    --card: #303034;
    --card-border: rgb(0 0 6 / 0.36);
    --shade: rgb(255 255 255 / 0.1);
    --shade-hover: rgb(255 255 255 / 0.15);
    --shade-active: rgb(255 255 255 / 0.2);
    --header: #2e2e32;
    --accent-text: #78aeed;
    --destructive-text: #ff7b63;
    --success: #8ff0a4;
    --warning: #f8e45c;
    --focus: rgb(120 174 237 / 0.6);
    --shadow: none;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
}

body {
  min-height: 100vh;
  min-height: 100dvh;
}

h1,
h2 {
  margin: 0 0 0.5rem;
  font-weight: 700;
  line-height: 1.25;
}

h1 {
  font-size: 1.4rem;
}

h2 {
  font-size: 1.1rem;
}

p {
  margin: 0 0 0.6rem;
}

.dim {
  color: var(--dim);
}

.small {
  font-size: 0.87rem;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* -- buttons ----------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 34px;
  padding: 0.3rem 0.85rem;
  border: 0;
  border-radius: var(--radius-small);
  background: var(--shade);
  color: inherit;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}

.btn:hover {
  background: var(--shade-hover);
}

.btn:active {
  background: var(--shade-active);
}

.btn.suggested {
  background: var(--accent);
  color: var(--on-accent);
}

.btn.suggested:hover {
  background: var(--accent-hover);
}

.btn.destructive {
  color: var(--destructive-text);
}

.btn.destructive-suggested {
  background: var(--destructive);
  color: #ffffff;
}

.btn.flat {
  background: transparent;
}

.btn.flat:hover {
  background: var(--shade);
}

.btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.link-button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent-text);
  font: inherit;
  font-size: 0.87rem;
  cursor: pointer;
}

.link-button:hover {
  text-decoration: underline;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 0.75rem;
}

.button-row:empty {
  display: none;
}

.icon {
  width: 16px;
  height: 16px;
  flex: none;
}

/* -- cards and centered pages ------------------------------------------------- */

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow), 0 0 0 1px var(--card-border);
}

.center-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 1rem;
}

.message,
.login {
  width: 100%;
  max-width: 440px;
  padding: 1.5rem;
}

.login {
  text-align: center;
}

.login .button-row {
  justify-content: center;
}

.banner {
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius-small);
  background: var(--shade);
}

.qr-box {
  display: flex;
  justify-content: center;
  margin: 1rem auto;
}

.qr {
  display: block;
  width: min(280px, 72vw);
  height: auto;
  border-radius: var(--radius-small);
}

.login-status {
  font-weight: 600;
  min-height: 1.45em;
}

.noscript {
  padding: 2rem;
  text-align: center;
}

/* -- header bar ---------------------------------------------------------------- */

.headerbar {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--header);
  box-shadow: 0 1px 0 var(--card-border);
}

.headerbar-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.25rem 0.75rem;
  max-width: 760px;
  margin: 0 auto;
  padding: 0.4rem 1rem;
}

.title-block {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
}

.app-title {
  font-weight: 700;
}

.status-chip {
  font-size: 0.8rem;
  padding: 0.05rem 0.5rem;
  border-radius: 999px;
  background: var(--shade);
  color: var(--dim);
}

.status-chip.online {
  color: var(--success);
}

.status-chip.offline {
  color: var(--warning);
}

.header-end {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.session-info {
  font-size: 0.85rem;
  color: var(--dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 520px) {
  .session-info {
    white-space: normal;
  }
}

/* -- page, composer --------------------------------------------------------------- */

.page {
  max-width: 760px;
  margin: 0 auto;
  padding: 1rem 1rem 4rem;
}

.composer {
  padding: 0.6rem;
  margin-bottom: 1rem;
}

.composer-text {
  display: block;
  width: 100%;
  min-height: 4.5rem;
  max-height: 40vh;
  resize: vertical;
  padding: 0.5rem 0.6rem;
  border: 0;
  border-radius: var(--radius-small);
  background: var(--shade);
  color: inherit;
  font: inherit;
}

.composer-text:focus-visible {
  outline-offset: 0;
}

.composer-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.composer-actions .hint {
  margin-left: auto;
}

@media (max-width: 520px) {
  .composer-actions .hint {
    display: none;
  }

  .composer-actions .suggested {
    margin-left: auto;
  }
}

/* -- list ------------------------------------------------------------------------------ */

.list {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow), 0 0 0 1px var(--card-border);
  overflow: hidden;
}

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.5rem 0.75rem;
  padding: 0.75rem 0.9rem;
}

.row + .row {
  border-top: 1px solid var(--card-border);
}

.row-icon {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: var(--shade);
  color: var(--dim);
}

.row.mine .row-icon {
  color: var(--accent-text);
}

.row.unreadable .row-icon {
  color: var(--warning);
}

.row-body {
  flex: 1 1 260px;
  min-width: 0;
}

.row-title {
  margin: 0;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.row-text {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.row-text.clamped {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 8;
  line-clamp: 8;
  overflow: hidden;
}

.row-meta {
  margin: 0.15rem 0 0;
  font-size: 0.85rem;
  color: var(--dim);
}

.status-failed .row-meta {
  color: var(--destructive-text);
}

.row-progress {
  display: block;
  width: 100%;
  height: 6px;
  margin-top: 0.4rem;
  border: 0;
  border-radius: 999px;
  background: var(--shade);
  appearance: none;
  -webkit-appearance: none;
  accent-color: var(--accent);
}

.row-progress::-webkit-progress-bar {
  background: var(--shade);
  border-radius: 999px;
}

.row-progress::-webkit-progress-value {
  background: var(--accent);
  border-radius: 999px;
}

.row-progress::-moz-progress-bar {
  background: var(--accent);
  border-radius: 999px;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: flex-end;
  margin-left: auto;
}

.row-actions .btn {
  min-height: 30px;
  padding: 0.2rem 0.7rem;
  font-size: 0.9rem;
}

@media (max-width: 520px) {
  .row-actions {
    width: 100%;
    padding-left: calc(32px + 0.75rem);
    justify-content: flex-start;
  }
}

.empty {
  padding: 2.5rem 1rem;
  text-align: center;
}

/* -- notices, drop overlay, dialog ------------------------------------------------------ */

.notices {
  position: fixed;
  left: 50%;
  bottom: 1rem;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  width: min(560px, calc(100vw - 2rem));
  transform: translateX(-50%);
  pointer-events: none;
}

.notice {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  max-width: 100%;
  padding: 0.55rem 0.6rem 0.55rem 1rem;
  border-radius: 999px;
  background: #3d3d41;
  color: #ffffff;
  box-shadow: 0 2px 8px rgb(0 0 0 / 0.25);
  pointer-events: auto;
}

.notice-close {
  flex: none;
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 999px;
  background: rgb(255 255 255 / 0.12);
  color: inherit;
  font: inherit;
  line-height: 1;
  cursor: pointer;
}

.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgb(53 132 228 / 0.16);
  pointer-events: none;
}

.drop-target {
  padding: 2rem 3rem;
  border: 2px dashed var(--accent);
  border-radius: var(--radius);
  background: var(--card);
  font-weight: 700;
}

.dialog {
  width: min(420px, calc(100vw - 2rem));
  padding: 1.25rem;
  border: 0;
  border-radius: var(--radius);
  background: var(--card);
  color: var(--fg);
  box-shadow: 0 4px 24px rgb(0 0 0 / 0.3);
}

.dialog::backdrop {
  background: rgb(0 0 0 / 0.35);
}

@media (prefers-reduced-motion: no-preference) {
  .notice {
    animation: notice-in 160ms ease-out;
  }

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