/* Desktop-only layout improvements. Mobile styles remain owned by each page. */
.desktop-control-label {
  display: none;
}

@media (min-width: 900px) {
  :root {
    --desktop-text-xs: 12px;
    --desktop-text-sm: 13px;
    --desktop-text-control: 14px;
    --desktop-text-body: 15px;
    --desktop-text-title: 16px;
    --desktop-text-heading: 20px;
  }

  html,
  body {
    overflow-x: clip;
  }

  /* Landing page */
  body.page-home .wrap {
    max-width: 1120px;
    margin-top: 56px;
    padding: 24px;
  }

  body.page-home .list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
  }

  body.page-home .card {
    min-height: 112px;
    justify-content: center;
  }

  body.page-home .title {
    font-size: 17px;
  }

  body.page-home .desc {
    font-size: 14px;
  }

  /* Event list */
  body.page-event {
    background: #f7f8fa !important;
    font-size: var(--desktop-text-body);
    line-height: 1.45;
  }

  body.page-event .topbar {
    padding: 28px 20px 16px !important;
  }

  body.page-event .topbar-row,
  body.page-event .app-content {
    width: min(100%, 1200px);
    margin-right: auto;
    margin-left: auto;
    box-sizing: border-box;
  }

  body.page-event .topbar-row {
    padding: 0 !important;
    align-items: center !important;
  }

  body.page-event .app-content {
    padding: 22px 24px 48px !important;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 20px;
    box-shadow: 0 10px 32px rgba(15, 23, 42, 0.06);
  }

  body.page-event .sheet-tabs,
  body.page-event #discount-buttons,
  body.page-event #volume-buttons,
  body.page-event .keyword-inline-panel .keyword-grid {
    flex-wrap: wrap !important;
    overflow: visible !important;
    white-space: normal !important;
    padding-right: 0 !important;
    padding-left: 0 !important;
    scrollbar-width: auto;
  }

  body.page-event .discount-scroll {
    overflow: visible !important;
  }

  body.page-event .sheet-tab,
  body.page-event .tabs-btn {
    font-size: var(--desktop-text-control) !important;
    padding: 7px 9px !important;
  }

  body.page-event button {
    font-size: var(--desktop-text-control) !important;
  }

  body.page-event .topbar-title {
    font-size: 22px !important;
    font-weight: 800 !important;
    line-height: 1.2 !important;
  }

  body.page-event .topbar-icon {
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    min-height: 44px !important;
    padding: 0 !important;
    font-size: 23px !important;
    line-height: 1 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  body.page-event .topbar-actions {
    gap: 8px !important;
    padding: 0 !important;
  }

  body.page-event .topbar-actions .topbar-icon:last-child {
    font-size: 27px !important;
  }

  body.page-event .topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
  }

  body.page-event .home-btn {
    width: 40px;
    height: 40px;
    padding: 8px !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  body.page-event .home-btn svg {
    width: 20px !important;
    height: 20px !important;
  }

  body.page-event .filter-pill,
  body.page-event .wish-clear-btn,
  body.page-event .wish-add-btn {
    padding: 7px 11px !important;
    font-size: var(--desktop-text-sm) !important;
  }

  body.page-event .dropdown-item {
    font-size: var(--desktop-text-control) !important;
  }

  body.page-event .search-row input,
  body.page-event .search-input,
  body.page-event .wish-input,
  body.page-event input,
  body.page-event select,
  body.page-event textarea {
    font-size: var(--desktop-text-body) !important;
  }

  body.page-event .search-icon-btn {
    width: 40px !important;
    height: 40px !important;
    font-size: 18px !important;
  }

  body.page-event .page-title {
    font-size: var(--desktop-text-heading) !important;
  }

  body.page-event .mobile-title,
  body.page-event .book-title,
  body.page-event .wish-search-title {
    font-size: var(--desktop-text-title) !important;
  }

  body.page-event .mobile-author,
  body.page-event .book-author,
  body.page-event .mobile-price,
  body.page-event .mobile-discount,
  body.page-event .wish-search-author,
  body.page-event .title-meta,
  body.page-event .mobile-price-line {
    font-size: var(--desktop-text-control) !important;
  }

  body.page-event table {
    font-size: var(--desktop-text-control) !important;
  }

  body.page-event th,
  body.page-event td {
    padding: 9px 8px;
  }

  body.page-event .modal-header {
    font-size: 18px !important;
  }

  body.page-event .filter-bar {
    justify-content: flex-start !important;
  }

  body.page-event .modal-sheet {
    width: min(720px, calc(100% - 48px));
    max-height: 82vh;
    border-radius: 18px;
    margin-bottom: 5vh;
  }

  /* Discount pages */
  body.page-discount .app-header,
  body.page-discount .app-content,
  body.page-discount-rank .app-header,
  body.page-discount-rank .app-content,
  body.page-discount-wishlist .app-header,
  body.page-discount-wishlist .app-content {
    width: min(100%, 1180px);
    margin-right: auto;
    margin-left: auto;
    box-sizing: border-box;
  }

  body.page-discount,
  body.page-discount-rank,
  body.page-discount-wishlist {
    font-size: var(--desktop-text-body);
    line-height: 1.45;
  }

  body.page-discount button,
  body.page-discount-rank button,
  body.page-discount-wishlist button {
    font-size: var(--desktop-text-control) !important;
  }

  body.page-discount input,
  body.page-discount-rank input,
  body.page-discount-wishlist input,
  body.page-discount select,
  body.page-discount-rank select,
  body.page-discount-wishlist select {
    font-size: var(--desktop-text-body) !important;
  }

  body.page-discount .app-title,
  body.page-discount-rank .app-title,
  body.page-discount-wishlist .app-title {
    font-size: 18px;
  }

  body.page-discount h2,
  body.page-discount-rank h2,
  body.page-discount-wishlist h2 {
    font-size: var(--desktop-text-heading);
  }

  body.page-discount .result-title,
  body.page-discount-rank .rank-title,
  body.page-discount-wishlist .wish-title {
    font-size: var(--desktop-text-title);
  }

  body.page-discount .result-author,
  body.page-discount-rank .rank-sub,
  body.page-discount-wishlist .wish-author {
    font-size: var(--desktop-text-control);
  }

  body.page-discount .app-header,
  body.page-discount-rank .app-header,
  body.page-discount-wishlist .app-header {
    padding-top: 28px;
  }

  body.page-discount .app-content,
  body.page-discount-rank .app-content,
  body.page-discount-wishlist .app-content {
    padding: 18px 24px 40px;
  }

  body.page-discount .sheet-menu-wrapper,
  body.page-discount-rank .top-actions {
    overflow: visible;
  }

  body.page-discount .sheet-menu,
  body.page-discount #discount-buttons,
  body.page-discount-rank .top-actions {
    flex-wrap: wrap;
    white-space: normal;
  }

  body.page-discount .sheet-menu {
    gap: 10px 24px;
  }

  body.page-discount .sheet-menu button {
    font-size: 18px !important;
  }

  /* Long filter groups stay compact until the user asks to expand them. */
  .desktop-control-shell {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: start;
  }

  .desktop-control-shell[hidden] {
    display: none;
  }

  .desktop-control-shell.has-label {
    grid-template-columns: 64px minmax(0, 1fr) auto;
    padding: 4px 0;
    border-bottom: 1px solid #eef0f3;
  }

  body.page-event .desktop-control-shell.has-label {
    min-height: 0;
  }

  body.page-event .desktop-control-shell.has-label .desktop-control-label {
    grid-column: 1;
  }

  body.page-event .desktop-control-shell.has-label > .desktop-control-toggle {
    grid-column: 3;
  }

  body.page-event .desktop-control-shell.has-label > .desktop-control-collapsible {
    position: static;
    width: 100%;
  }

  .desktop-control-label {
    display: block;
    padding: 9px 0 0 2px;
    color: #6b7280;
    font-size: var(--desktop-text-sm);
    font-weight: 800;
    line-height: 1;
  }

  .desktop-control-collapsible {
    max-height: var(--desktop-collapsed-height, 48px);
    box-sizing: border-box;
    overflow: hidden !important;
    align-content: flex-start;
  }

  body.page-event .sheet-tabs.desktop-control-collapsible,
  body.page-event #discount-buttons.desktop-control-collapsible,
  body.page-event #volume-buttons.desktop-control-collapsible {
    overflow: hidden !important;
  }

  body.page-event .sheet-tabs.desktop-control-collapsible.is-expanded,
  body.page-event #discount-buttons.desktop-control-collapsible.is-expanded,
  body.page-event #volume-buttons.desktop-control-collapsible.is-expanded {
    max-height: none;
    overflow: visible !important;
  }

  .desktop-control-collapsible.is-expanded {
    max-height: none;
  }

  .desktop-control-toggle {
    min-width: 66px;
    height: 34px;
    margin-top: 6px;
    padding: 0 12px;
    border: 1px solid #d1d5db;
    border-radius: 999px;
    background: #fff;
    color: #374151;
    font-size: var(--desktop-text-sm) !important;
    font-weight: 700;
    cursor: pointer;
  }

  .desktop-control-toggle:hover {
    background: #f3f4f6;
  }

  .desktop-control-toggle[hidden] {
    display: none;
  }

  /* Skip layout and paint work for off-screen rows in the very long event list. */
  body.page-event #result .mobile-row,
  body.page-event #wishlistResult .wish-book-entry,
  body.page-event #upResult .mobile-row {
    content-visibility: auto;
    contain-intrinsic-size: auto 74px;
  }

  /* Keyword categories are separate cards on desktop. */
  body.page-event #keywordModal .modal-sheet,
  body.page-event #wishKeywordModal .modal-sheet {
    width: min(960px, calc(100% - 48px));
  }

  body.page-event #keywordModal .keyword-inline-panel,
  body.page-event #wishKeywordModal .keyword-inline-panel {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-top: 16px;
  }

  body.page-event #keywordModal .keyword-group-row,
  body.page-event #wishKeywordModal .keyword-group-row {
    display: block;
    padding: 14px;
    border: 1px solid #e5e7eb;
    border-left-width: 4px;
    border-radius: 14px;
    background: #f9fafb;
  }

  body.page-event #keywordModal .keyword-group-row:last-child,
  body.page-event #wishKeywordModal .keyword-group-row:last-child {
    grid-column: 1 / -1;
  }

  body.page-event #keywordModal .keyword-group-title,
  body.page-event #wishKeywordModal .keyword-group-title {
    margin: 0 0 10px;
    color: #111827;
    font-size: var(--desktop-text-body);
    font-weight: 800;
  }

  body.page-event #keywordModal .keyword-grid,
  body.page-event #wishKeywordModal .keyword-grid {
    display: flex;
    flex-wrap: wrap !important;
    gap: 7px;
    overflow: visible !important;
    padding: 0 !important;
  }

  body.page-event #keywordModal .keyword-pill,
  body.page-event #wishKeywordModal .keyword-pill {
    padding: 6px 9px;
    background: #fff;
    font-size: var(--desktop-text-sm) !important;
  }

  body.page-event :is(#keywordModal, #wishKeywordModal) .keyword-group-row:nth-child(7n + 1) { border-left-color: #6366f1; }
  body.page-event :is(#keywordModal, #wishKeywordModal) .keyword-group-row:nth-child(7n + 2) { border-left-color: #ec4899; }
  body.page-event :is(#keywordModal, #wishKeywordModal) .keyword-group-row:nth-child(7n + 3) { border-left-color: #3b82f6; }
  body.page-event :is(#keywordModal, #wishKeywordModal) .keyword-group-row:nth-child(7n + 4) { border-left-color: #14b8a6; }
  body.page-event :is(#keywordModal, #wishKeywordModal) .keyword-group-row:nth-child(7n + 5) { border-left-color: #f59e0b; }
  body.page-event :is(#keywordModal, #wishKeywordModal) .keyword-group-row:nth-child(7n + 6) { border-left-color: #8b5cf6; }
  body.page-event :is(#keywordModal, #wishKeywordModal) .keyword-group-row:nth-child(7n + 7) { border-left-color: #6b7280; }

  body.page-discount .graph-modal-content,
  body.page-discount-wishlist .graph-modal-content {
    width: min(900px, calc(100% - 64px));
    box-sizing: border-box;
  }

  /* Calendar */
  body.page-calendar .app-header,
  body.page-calendar .platform-tabs,
  body.page-calendar .calendar-nav,
  body.page-calendar .calendar {
    width: min(100%, 1200px);
    margin-right: auto;
    margin-left: auto;
    box-sizing: border-box;
  }

  body.page-calendar,
  body.page-calendar-list {
    font-size: var(--desktop-text-body);
  }

  body.page-calendar button,
  body.page-calendar-list button {
    font-size: var(--desktop-text-control);
  }

  body.page-calendar-list .app-header,
  body.page-calendar-list .platform-tabs,
  body.page-calendar-list .date-header,
  body.page-calendar-list .list,
  body.page-calendar-list .footer {
    width: min(100%, 900px);
    margin-right: auto;
    margin-left: auto;
    box-sizing: border-box;
  }

  /* Calculator */
  html:has(body.page-calculator) {
    background: #f2f2f7;
  }

  body.page-calculator {
    width: min(100%, 780px);
    margin: 0 auto;
    padding: 40px 32px;
    box-sizing: border-box;
  }

  body.page-calculator {
    font-size: var(--desktop-text-body);
    line-height: 1.45;
  }

  body.page-calculator h2 {
    font-size: var(--desktop-text-heading);
  }

  body.page-calculator button,
  body.page-calculator textarea {
    font-size: var(--desktop-text-body);
  }
}
