:root {
  color-scheme: light;
  --page: #f4f6f9;
  --surface: #ffffff;
  --surface-muted: #f7f9fc;
  --text: #101820;
  --muted: #5d6875;
  --line: #dbe1e8;
  --blue: #075cbd;
  --blue-dark: #064b99;
  --focus: #78aef1;
  --success: #147a45;
  --error: #b42318;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--page);
}

body {
  min-height: 100svh;
  margin: 0;
  color: var(--text);
  background: var(--page);
  -webkit-font-smoothing: antialiased;
}

button,
input,
textarea {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  width: 100%;
  max-width: 480px;
  min-height: 100svh;
  margin: 0 auto;
  padding:
    max(10px, env(safe-area-inset-top))
    max(12px, env(safe-area-inset-right))
    max(12px, env(safe-area-inset-bottom))
    max(12px, env(safe-area-inset-left));
  background: var(--surface);
}

.brand {
  margin: 0 0 8px;
}

.brand__logo {
  display: block;
  width: min(100%, 160px);
  height: auto;
  margin: 0 auto;
}

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

#message-form {
  display: grid;
  gap: 8px;
}

.field {
  display: grid;
  gap: 4px;
}

label {
  font-size: 0.875rem;
  font-weight: 700;
  line-height: 1.125rem;
}

input {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  background: var(--surface);
  font-size: 1rem;
  outline: none;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

input::placeholder {
  color: #687482;
  opacity: 1;
}

input:focus-visible {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 38%, transparent);
}

.field__hint {
  display: none;
  margin: 0 1px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.4;
}

.preview {
  position: relative;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-muted);
}

.preview__heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 18px;
  gap: 8px;
  padding-right: 52px;
  margin-bottom: 4px;
}

h2 {
  margin: 0;
  font-size: 0.875rem;
  line-height: 18px;
  letter-spacing: -0.01em;
}

.clear-button {
  position: absolute;
  top: 0;
  right: 4px;
  min-width: 44px;
  min-height: 44px;
  margin: 0;
  padding: 0 8px;
  border: 0;
  color: var(--blue);
  background: transparent;
  font-size: 0.875rem;
  font-weight: 700;
  cursor: pointer;
}

.clear-button:disabled {
  color: #9aa3ad;
  cursor: default;
}

#message-preview {
  display: block;
  width: 100%;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  resize: none;
  border: 0;
  border-radius: 0;
  outline: none;
  color: #2d3742;
  background: transparent;
  font-size: 1rem;
  line-height: 1.4;
  white-space: pre-wrap;
}

#message-preview:focus-visible {
  border-radius: 5px;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 38%, transparent);
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.actions.share-unavailable {
  grid-template-columns: 1fr;
}

.button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 0.9375rem;
  font-weight: 750;
  line-height: 1;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease, transform 80ms ease;
}

.button:active:not(:disabled) {
  transform: scale(0.985);
}

.button:focus-visible,
.clear-button:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus) 55%, transparent);
  outline-offset: 2px;
}

.button--primary {
  color: #ffffff;
  background: var(--blue);
}

.button--primary:hover:not(:disabled) {
  background: var(--blue-dark);
}

.button--secondary {
  border-color: #b9c6d3;
  color: var(--blue-dark);
  background: var(--surface);
}

.button--secondary:hover:not(:disabled) {
  border-color: var(--blue);
  background: #f2f7fd;
}

.actions.share-unavailable .button--secondary {
  border-color: transparent;
  color: #ffffff;
  background: var(--blue);
}

.button:disabled {
  border-color: transparent;
  color: #8a939d;
  background: #e7ebef;
  cursor: default;
}

.status {
  margin: 0 2px;
  min-height: 16px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 650;
  line-height: 16px;
  text-align: center;
}

.status[data-tone="success"] {
  color: var(--success);
}

.status[data-tone="error"] {
  color: var(--error);
}

footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.75rem;
}

footer p {
  margin: 0;
}

.privacy-icon {
  width: 15px;
  height: 15px;
  fill: currentColor;
}

@media (max-width: 360px) and (max-height: 600px) {
  .app-shell {
    padding-top: max(8px, env(safe-area-inset-top));
  }

  .brand {
    margin-bottom: 4px;
  }

  .brand__logo {
    width: 116px;
  }

  #message-form {
    gap: 6px;
  }

  .preview {
    padding: 8px 10px;
  }

  #message-preview {
    line-height: 1.32;
  }

  footer {
    display: none;
  }
}

@media (min-width: 540px) {
  body {
    padding: 32px 0;
  }

  .app-shell {
    min-height: auto;
    padding: 32px 36px;
    border: 1px solid #e1e6ec;
    border-radius: 24px;
    box-shadow: 0 18px 48px rgb(30 43 58 / 8%);
  }

  .brand {
    margin-bottom: 20px;
  }

  .brand__logo {
    width: 220px;
    margin-left: 0;
  }

  #message-form {
    gap: 16px;
  }

  .field {
    gap: 7px;
  }

  label,
  h2 {
    font-size: 0.92rem;
  }

  input {
    min-height: 50px;
    padding: 0 15px;
    border-radius: 12px;
  }

  .field__hint {
    display: block;
  }

  .preview {
    padding: 16px;
    border-radius: 16px;
  }

  .preview__heading {
    margin-bottom: 10px;
  }

  #message-preview {
    font-size: 1rem;
    line-height: 1.5;
  }

  .actions {
    gap: 10px;
  }

  .button {
    min-height: 50px;
    padding: 0 20px;
    border-radius: 12px;
    font-size: 1rem;
  }

  .status {
    font-size: 0.8rem;
    line-height: 1.4;
  }

  footer {
    margin-top: 22px;
    font-size: 0.76rem;
  }
}

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