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

body {
  margin: 0;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: #1f2933;
  background: #f8f9fa;
}

h1 {
  margin: 0 0 0.75rem;
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.25;
}

h2 {
  margin: 0 0 0.5rem;
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.3;
}

a {
  color: #d84315;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

code {
  font-size: 0.85em;
  background: rgba(31, 41, 51, 0.06);
  padding: 0.15em 0.35em;
  border-radius: 6px;
}

hr {
  border: none;
  border-top: 1px solid rgba(31, 41, 51, 0.08);
  margin: 1.25rem 0;
}

.muted {
  margin: 0.75rem 0 0;
  color: #6b7280;
  font-size: 0.875rem;
}

.error {
  margin: 0 0 1rem;
  padding: 0.65rem 0.75rem;
  background: #fdecea;
  color: #d32f2f;
  border-radius: 10px;
  font-size: 0.875rem;
}

.notice {
  margin: 0 0 1rem;
  padding: 0.65rem 0.75rem;
  background: #e8f5e9;
  color: #1b5e20;
  border-radius: 10px;
  font-size: 0.875rem;
}

.brand {
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #1f2933;
  text-decoration: none;
}

.brand:hover {
  text-decoration: none;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.45rem 0.9rem;
  border-radius: 10px;
  border: 1px solid transparent;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
}

.btn:hover {
  text-decoration: none;
}

.btn-text {
  background: transparent;
  color: #1f2933;
}

.btn-text:hover {
  background: rgba(31, 41, 51, 0.04);
}

.btn-primary {
  background: #f4511e;
  color: #fff;
}

.btn-primary:hover {
  background: #e64a19;
}

.btn-outline {
  background: #fff;
  color: #f4511e;
  border-color: rgba(244, 81, 30, 0.45);
}

.btn-outline:hover {
  background: rgba(244, 81, 30, 0.06);
}

.public-page {
  min-height: 100vh;
}

.public-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(31, 41, 51, 0.08);
}

.public-bar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.85rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.public-bar-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.public-main,
.auth-main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem 3rem;
}

.auth-main {
  display: flex;
  justify-content: center;
}

.surface {
  background: #fff;
  border: 1px solid rgba(31, 41, 51, 0.08);
  border-radius: 16px;
  box-shadow: 0 1px 2px rgba(31, 41, 51, 0.04);
  padding: 1.35rem 1.5rem;
}

.auth-card {
  width: 100%;
  max-width: 22rem;
}

.nav-toggle {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.app-frame {
  display: flex;
  min-height: 100vh;
  align-items: stretch;
}

.sidebar {
  width: 240px;
  flex: 0 0 240px;
  background: #fff;
  border-right: 1px solid rgba(31, 41, 51, 0.08);
  display: flex;
  flex-direction: column;
  padding: 1.25rem 0 1rem;
  min-height: 100vh;
}

.sidebar-brand {
  padding: 0 1.25rem 0.85rem;
}

.sidebar-email {
  margin: 0.15rem 0 0;
  color: #6b7280;
  font-size: 0.8125rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0 0.65rem;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  padding: 0.45rem 0.7rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #6b7280;
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.nav-item:hover {
  background: rgba(31, 41, 51, 0.04);
  color: #1f2933;
  text-decoration: none;
}

.nav-item.active {
  background: rgba(244, 81, 30, 0.08);
  color: #f4511e;
  font-weight: 600;
}

.nav-icon {
  width: 1.15rem;
  height: 1.15rem;
  flex: 0 0 auto;
}

.sidebar-footer {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  margin-top: 0.75rem;
  padding: 0.75rem 0.65rem 0;
  border-top: 1px solid rgba(31, 41, 51, 0.08);
}

.sidebar-footer form {
  margin: 0;
}

.sidebar-context {
  padding: 0.35rem 1.25rem 0.15rem;
}

.sidebar-horse {
  display: block;
  color: #1f2933;
  font-size: 0.8125rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-horse:hover {
  color: #f4511e;
}

.nav-backdrop {
  display: none;
}

.mobile-bar {
  display: none;
}

.app-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.main {
  flex: 1;
  width: 100%;
  max-width: 1200px;
  padding: 1.75rem 2rem 2.5rem;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-width: 36rem;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.875rem;
  font-weight: 600;
}

input,
select,
textarea {
  padding: 0.5rem 0.7rem;
  border: 1px solid rgba(31, 41, 51, 0.16);
  border-radius: 10px;
  background: #fff;
  color: inherit;
  font: inherit;
  font-weight: 400;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #f4511e;
  box-shadow: 0 0 0 3px rgba(244, 81, 30, 0.16);
}

main button[type="submit"]:not(.linkish) {
  margin-top: 0.25rem;
  padding: 0.55rem 1rem;
  border: none;
  border-radius: 10px;
  background: #f4511e;
  color: #fff;
  font: inherit;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: none;
}

main button[type="submit"]:not(.linkish):hover {
  background: #e64a19;
}

.btn-add {
  display: inline-flex;
  align-items: center;
  padding: 0.45rem 0.9rem;
  border: 1px solid #f4511e;
  border-radius: 10px;
  background: #fff;
  color: #f4511e;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}

.btn-add:hover {
  background: rgba(244, 81, 30, 0.08);
  text-decoration: none;
}

button.linkish {
  background: none;
  border: none;
  color: #6b7280;
  font: inherit;
  font-size: 0.875rem;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
}

form.inline {
  display: inline;
  margin: 0;
}

.add-horse-toolbar {
  margin: 0 0 0.75rem;
}

.add-horse-panel[hidden] {
  display: none;
}

.add-horse-panel:not([hidden]) {
  max-width: 40rem;
  margin-top: 0.25rem;
  margin-bottom: 1.25rem;
  background: #fff;
  border: 1px solid rgba(31, 41, 51, 0.08);
  border-radius: 16px;
  box-shadow: 0 1px 2px rgba(31, 41, 51, 0.04);
  padding: 1.25rem 1.35rem 0.35rem;
}

.row {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.row-actions {
  display: flex;
  gap: 0.85rem;
  align-items: center;
  margin-left: auto;
  flex-wrap: wrap;
}

.tabs {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
  margin: 0.35rem 0 1.25rem;
  border-bottom: 1px solid rgba(31, 41, 51, 0.08);
}

.tab {
  display: inline-block;
  padding: 0.45rem 0.75rem 0.55rem;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  color: #6b7280;
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
}

.tab:hover {
  color: #1f2933;
  text-decoration: none;
}

.tab.active {
  color: #f4511e;
  font-weight: 600;
  border-bottom-color: #f4511e;
}

.log-list {
  display: grid;
  gap: 0.75rem;
}

.log-card,
.horse-card {
  background: #fff;
  border: 1px solid rgba(31, 41, 51, 0.08);
  border-radius: 16px;
  box-shadow: 0 1px 2px rgba(31, 41, 51, 0.04);
}

.log-card {
  padding: 0.9rem 1rem;
}

.prewrap {
  white-space: pre-wrap;
}

.horse-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
}

.horse-card {
  overflow: hidden;
  padding: 0.85rem;
  display: grid;
  gap: 0.75rem;
}

.horse-photo {
  width: 100%;
  height: 180px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid rgba(31, 41, 51, 0.08);
}

.horse-photo.hero {
  max-width: 40rem;
  height: 260px;
  margin: 0.75rem 0 1rem;
  border-radius: 16px;
}

.horse-meta {
  display: grid;
  gap: 0.25rem;
}

.horse-title {
  display: flex;
  gap: 0.5rem;
  align-items: baseline;
  flex-wrap: wrap;
}

.horse-banner {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin: 0 0 0.85rem;
  padding: 0.7rem 0.85rem;
  border: 1px solid rgba(31, 41, 51, 0.08);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(31, 41, 51, 0.04);
}

.horse-banner-photo,
.horse-banner-fallback {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  flex: 0 0 auto;
  border: 1px solid rgba(31, 41, 51, 0.08);
  background: #f8f9fa;
}

.horse-banner-photo {
  object-fit: cover;
  display: block;
}

.horse-banner-fallback {
  display: grid;
  place-items: center;
  font-weight: 600;
  color: #1f2933;
  font-size: 1.05rem;
}

.horse-banner-text {
  display: grid;
  gap: 0.1rem;
  min-width: 0;
}

.horse-banner-name {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1.2;
}

.horse-banner-link {
  font-size: 0.8125rem;
  font-weight: 600;
  text-decoration: none;
}

.horse-banner-link:hover {
  text-decoration: underline;
}

.ai-layout {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.ai-chats,
.ai-thread {
  min-width: 0;
  background: #fff;
  border: 1px solid rgba(31, 41, 51, 0.08);
  border-radius: 16px;
  box-shadow: 0 1px 2px rgba(31, 41, 51, 0.04);
  padding: 0.9rem;
}

.ai-chat-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-height: 11rem;
  overflow: auto;
}

.ai-list-empty {
  margin: 0;
  color: #6b7280;
  font-size: 0.875rem;
}

.ai-chat-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.ai-chat-open {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
  padding: 0.45rem 0.65rem;
  border: 1px solid rgba(31, 41, 51, 0.12);
  border-radius: 8px;
  background: #fff;
  color: #1f2933;
  font: inherit;
  cursor: pointer;
}

.ai-chat-item.active .ai-chat-open {
  border-color: #f4511e;
  color: #f4511e;
  background: rgba(244, 81, 30, 0.08);
}

.ai-messages {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-height: 12rem;
  max-height: 24rem;
  overflow: auto;
  padding-right: 0.15rem;
}

.ai-msg {
  max-width: 85%;
  padding: 0.65rem 0.75rem;
  border-radius: 12px;
  border: 1px solid rgba(31, 41, 51, 0.08);
  background: #f8f9fa;
}

.ai-msg.user {
  align-self: flex-end;
  background: rgba(244, 81, 30, 0.08);
  border-color: rgba(244, 81, 30, 0.18);
}

.ai-msg.assistant {
  align-self: flex-start;
}

.ai-msg-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.ai-msg-images,
.ai-image-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.ai-msg-images {
  margin-top: 0.45rem;
}

.ai-msg-images img,
.ai-file-chip img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid rgba(31, 41, 51, 0.08);
  background: #fff;
}

.ai-file-chip {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  max-width: 100%;
  font-size: 0.85rem;
}

.ai-file-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-composer {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.ai-label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.875rem;
  font-weight: 600;
}

.ai-composer textarea {
  width: 100%;
}

.ai-composer-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.ai-composer button[type="submit"] {
  margin-top: 0;
}

.ai-composer button:disabled,
.ai-chats button:disabled,
.ai-composer textarea:disabled {
  opacity: 0.6;
  cursor: default;
}

.ai-attach {
  margin: 0;
  cursor: pointer;
}

.ai-note {
  margin: 0;
  color: #6b7280;
  font-size: 0.8rem;
}

@media (max-width: 899px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 40;
    transform: translateX(-105%);
    transition: transform 0.18s ease;
    box-shadow: none;
  }

  .nav-toggle:checked ~ .app-frame .sidebar {
    transform: translateX(0);
    box-shadow: 0 8px 24px rgba(31, 41, 51, 0.12);
  }

  .nav-toggle:checked ~ .app-frame .nav-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(31, 41, 51, 0.28);
    z-index: 30;
  }

  .mobile-bar {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    position: sticky;
    top: 0;
    z-index: 20;
    min-height: 52px;
    padding: 0.4rem 0.75rem;
    background: #fff;
    border-bottom: 1px solid rgba(31, 41, 51, 0.08);
  }

  .nav-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 8px;
    color: #1f2933;
    cursor: pointer;
  }

  .nav-toggle-btn svg {
    width: 1.35rem;
    height: 1.35rem;
  }

  .main {
    width: 90%;
    margin: 0 auto;
    padding: 1.15rem 0 2rem;
  }
}

.landing-hero {
  min-height: 17.5rem;
  display: flex;
  align-items: flex-end;
  background: linear-gradient(
    120deg,
    #1f2933 0%,
    #2e7d32 58%,
    #c2410c 100%
  );
}

.landing-hero-inner {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 3.5rem 1.5rem 3.25rem;
}

.landing-kicker {
  margin: 0 0 0.5rem;
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.75rem;
  letter-spacing: 0.02em;
}

.landing-hero h1 {
  margin: 0 0 0.5rem;
  max-width: 40rem;
  color: #fff;
  font-size: 1.75rem;
  font-weight: 600;
  line-height: 1.2;
}

.landing-hero p {
  margin: 0;
  max-width: 35rem;
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.95rem;
}

.landing-main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem 3.5rem;
}

.landing-cards {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: -1.35rem;
}

.surface-accent {
  position: relative;
  overflow: hidden;
  padding-left: 1.35rem;
}

.surface-accent::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: linear-gradient(
    180deg,
    var(--accent, #f4511e) 0%,
    color-mix(in srgb, var(--accent, #f4511e) 35%, transparent) 100%
  );
}

.surface-accent h2 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.65rem;
  font-size: 1rem;
}

.surface-accent h2 svg {
  width: 1.15rem;
  height: 1.15rem;
  flex: 0 0 auto;
  color: var(--accent, #f4511e);
}

.surface-accent .btn {
  margin-top: 1rem;
}

.landing-story {
  margin-top: 1.25rem;
}

.landing-story h2 {
  font-size: 1.35rem;
}

.landing-copy {
  margin-top: 0.35rem;
}

.landing-plans {
  margin-top: 2rem;
}

.landing-plans h2 {
  margin: 0 0 0.25rem;
  font-size: 1.35rem;
}

.plan-grid {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1rem;
}

.plan-card {
  display: flex;
  flex-direction: column;
}

.plan-name {
  margin: 0;
  color: #6b7280;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.plan-price {
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
  margin: 0.35rem 0 1rem;
}

.plan-price strong {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.plan-price span {
  color: #6b7280;
  font-size: 0.875rem;
}

.plan-card .check-list {
  flex: 1;
  margin-bottom: 0;
}

.plan-card .btn,
.plan-card button[type="submit"],
.plan-card button[type="button"] {
  width: 100%;
  margin-top: 1.25rem;
}

.plan-card.is-current {
  border: 2px solid #f4511e;
}

.membership-note {
  margin-bottom: 1rem;
}

.plan-card button[type="submit"].btn-outline,
.plan-card button[type="button"]:disabled {
  background: #fff;
  border: 1px solid rgba(31, 41, 51, 0.16);
}

.plan-card button[type="submit"].btn-outline {
  color: #f4511e;
  border-color: rgba(244, 81, 30, 0.45);
}

.plan-card button[type="submit"].btn-outline:hover {
  background: rgba(244, 81, 30, 0.06);
}

.plan-card button[type="button"]:disabled {
  color: #6b7280;
  cursor: default;
}

.landing-story .check-list + h2 {
  margin-top: 1.5rem;
}

.check-list {
  list-style: none;
  margin: 0 0 0.25rem;
  padding: 0;
}

.check-list li {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.22rem 0;
  color: #6b7280;
  font-size: 0.875rem;
}

.check-list svg {
  width: 1.15rem;
  height: 1.15rem;
  flex: 0 0 auto;
  margin-top: 0.05rem;
  color: #f4511e;
}

.landing-copy {
  margin-bottom: 0;
}

@media (min-width: 900px) {
  .landing-hero {
    min-height: 22.5rem;
  }

  .landing-hero h1 {
    font-size: 2.25rem;
  }

  .landing-cards {
    flex-direction: row;
    margin-top: -1.75rem;
  }

  .landing-cards .surface {
    flex: 1;
  }

  .plan-grid {
    flex-direction: row;
    align-items: stretch;
  }

  .plan-card {
    flex: 1;
  }

  .sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
  }

  .ai-layout {
    display: grid;
    grid-template-columns: 16rem minmax(0, 1fr);
    gap: 1rem;
    align-items: stretch;
    min-height: 32rem;
  }

  .ai-chats {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
  }

  .ai-chat-list {
    max-height: 32rem;
  }

  .ai-thread {
    display: flex;
    flex-direction: column;
    min-height: 32rem;
  }

  .ai-messages {
    flex: 1;
    max-height: 36rem;
  }
}
