/* Shared chrome: reset, body, header. Page-specific styles live with their app. */
* { box-sizing: border-box; }
/* min-height + column flex keeps the footer pinned to the bottom of the
   viewport on short pages (e.g. login), instead of floating right under
   the content with empty space below it. main grows to fill the gap;
   page-specific main styles (merge.css's grid, .auth-form's centering)
   are unaffected since flex here only governs main's own sizing as a
   flex item of body, not how it lays out its own children. */
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font-body); min-height: 100vh; display: flex; flex-direction: column; }
/* width:100% + min-width:0 override two flex-item defaults that otherwise
   fight each other on a page whose main has a wide descendant (e.g.
   my_files.css's min-width:600px table): per-page main.*-layout rules
   center themselves with "max-width + margin:0 auto", and auto margins on
   a flex item suppress the default stretch-to-fill behavior, falling back
   to a fit-content width that can't shrink below that descendant's
   intrinsic size - silently stretching the whole page past the viewport
   instead of letting that one element's own overflow-x:auto handle it.
   Forcing width:100% up front (max-width then still caps it on wide
   screens) sidesteps that fit-content calculation entirely. */
main { flex: 1 0 auto; width: 100%; min-width: 0; }
a { color: var(--link); }
button { font: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

.header { height: 72px; padding: 0 64px; display: flex; align-items: center; justify-content: space-between; background: var(--surface); border-bottom: 1px solid var(--border); position: relative; }
.left, .right { display: flex; align-items: center; }
.left { gap: 48px; }
.menu-panel { display: flex; align-items: center; gap: 12px; }
.menu-toggle { display: none; width: 44px; height: 44px; align-items: center; justify-content: center; border: 1px solid var(--border); border-radius: var(--radius-md); background: transparent; color: var(--text); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 600; font-size: 18px; }
.header nav { display: flex; gap: 28px; font-size: 15px; }
.header nav a { color: var(--muted); text-decoration: none; padding: 24px 0; border-bottom: 2px solid transparent; }
.header nav a[aria-current] { color: var(--text); font-weight: 500; border-bottom-color: var(--accent); }

.site-footer { max-width: 1440px; margin: 0 auto; padding: 32px 64px 48px; display: flex; flex-wrap: wrap; gap: 12px 32px; align-items: center; justify-content: space-between; color: var(--muted); font-size: 13px; }
.site-footer nav { display: flex; gap: 20px; flex-wrap: wrap; }
.site-footer nav a { color: var(--muted); text-decoration: none; }
.site-footer nav a:hover { color: var(--text); text-decoration: underline; }

/* Long-form prose (privacy/terms/cookies pages): narrower than the merge
   layout, comfortable line length and spacing for reading, not scanning. */
.legal-page { max-width: 760px; margin: 0 auto; padding: 48px 20px 80px; }
.legal-page h1 { font-size: 34px; margin: 0 0 8px; }
.legal-page .legal-updated { color: var(--muted); font-size: 14px; margin: 0 0 24px; }
.legal-page h2 { font-size: 20px; margin: 36px 0 12px; }
.legal-page h3 { font-size: 16px; margin: 24px 0 8px; }
.legal-page p, .legal-page li { font-size: 15px; line-height: 1.7; color: var(--text); }
.legal-page ul, .legal-page ol { padding-left: 22px; }
.legal-page li { margin-bottom: 6px; }
.legal-page a { color: var(--link); }
.legal-page table { width: 100%; border-collapse: collapse; margin: 16px 0; font-size: 14px; }
.legal-page th, .legal-page td { text-align: left; padding: 10px 12px; border: 1px solid var(--border); vertical-align: top; }
.legal-page th { background: var(--well); font-weight: 600; }
.legal-page code { background: var(--well); border-radius: 4px; padding: 1px 5px; font-size: 0.9em; }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; border: 1px solid var(--border); border-radius: var(--radius-md); background: transparent; color: var(--muted); }
.link-btn { height: 44px; display: flex; align-items: center; padding: 0 16px; color: var(--text); text-decoration: none; font-weight: 500; font-size: 15px; }
.soft-btn { height: 44px; display: flex; align-items: center; padding: 0 18px; border-radius: var(--radius-md); background: var(--accent-soft); color: var(--accent-soft-text); text-decoration: none; font-weight: 600; font-size: 15px; }

.account-menu { position: relative; }
.account-menu-toggle { gap: 6px; border: 0; background: transparent; font: inherit; cursor: pointer; }
.account-menu-panel { display: none; flex-direction: column; gap: 2px; position: absolute; top: 100%; right: 0; margin-top: 8px; min-width: 200px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 8px; box-shadow: var(--shadow-page); z-index: 20; }
.account-menu-panel.open { display: flex; }
.account-menu-email { display: flex; flex-direction: column; gap: 3px; padding: 8px 12px 10px; margin-bottom: 4px; border-bottom: 1px solid var(--border); }
.account-menu-email-text { color: var(--text); font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-menu-plan { color: var(--muted); font-size: 12px; }
.account-menu-plan--pro { color: var(--accent); font-weight: 600; }
.account-menu-panel a, .account-menu-panel button { display: block; width: 100%; padding: 8px 12px; border: 0; border-radius: var(--radius-sm); background: none; color: var(--text); text-decoration: none; font: inherit; font-weight: 500; font-size: 14px; text-align: left; cursor: pointer; }
.account-menu-panel a:hover, .account-menu-panel button:hover { background: var(--well); }
.account-menu-signout { margin: 4px 0 0; padding-top: 4px; border-top: 1px solid var(--border); }
.account-menu-signout button { margin: 0; }

.messages { list-style: none; margin: 0 0 24px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.message { padding: 12px 16px; border-radius: var(--radius-md); background: var(--well); color: var(--text); font-size: 14px; border: 1px solid var(--border); }
.message-error { border-color: color-mix(in srgb, var(--accent) 40%, red); }

/* Simple auth forms (accounts app) reuse .field/.primary from merge.css but
   need their own container width since they're not part of the merge layout.
   Wider than a typical auth form (420px -> 520px) so a full email address
   is visible without scrolling inside the input. */
.auth-form { max-width: 520px; margin: 64px auto; display: flex; flex-direction: column; gap: 24px; }
/* <form> itself isn't a flex child's concern - without this its own children
   (each .field, the submit button) have zero gap and sit flush against
   each other, regardless of .auth-form's own gap above. */
.auth-form form { display: flex; flex-direction: column; gap: 20px; }

@media (max-width: 720px) {
  .header { padding-left: 20px; padding-right: 20px; }
  .header nav { display: none; }
  .menu-toggle { display: flex; }
  .menu-panel {
    display: none;
    position: absolute;
    top: 100%;
    right: 20px;
    left: 20px;
    margin-top: 8px;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 12px;
    box-shadow: var(--shadow-page);
    z-index: 20;
  }
  .menu-panel.open { display: flex; }
  .menu-panel .icon-btn { align-self: flex-start; }
  .menu-panel .link-btn,
  .menu-panel .soft-btn {
    width: 100%;
    justify-content: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  /* The hamburger menu is already the one toggle on mobile - no need for a
     second, nested dropdown inside it. Hide the "My Account" trigger and
     show its panel inline, flattened into the surrounding menu-panel. */
  .account-menu { width: 100%; }
  .account-menu-toggle { display: none; }
  .account-menu-panel {
    display: flex;
    position: static;
    min-width: 0;
    margin-top: 0;
    padding: 0;
    border: 0;
    box-shadow: none;
    background: transparent;
  }
  .account-menu-email { text-align: center; }
  .account-menu-panel a, .account-menu-panel button { text-align: center; }
  .site-footer { padding-left: 20px; padding-right: 20px; flex-direction: column; align-items: flex-start; }
}
