/* Legacy responsive rules extracted from web/index.html.
   Kept below the new mobile layer during migration; new phone work must not be added here. */

@media (max-width:760px) {
      .causal-timeline { padding-left:22px; }
      .causal-timeline::before { left:7px; transform:none; }
      .causal-entry { width:100%; justify-self:stretch !important; }
      .causal-entry::before, .causal-entry:nth-child(odd)::before, .causal-entry:nth-child(even)::before {
        left:-21px; right:auto;
      }
    }

@media(max-width:560px){ .hall-total-progress{grid-template-columns:1fr auto;} .hall-progress-track{grid-column:1/-1;} }

@media(max-width:680px){ .hall-fork{grid-template-columns:1fr;} }

@media (max-width:680px) { .credential-card { grid-template-columns:1fr; } }

@media (max-width:700px) { .capability-parameter-row { grid-template-columns:1fr 92px auto; } .capability-parameter-key { grid-column:1/-1; } }

@media (max-width:620px) {
      #capabilityDialog .identity-form { padding:22px 20px; }
      .capability-heading { align-items:flex-start; }
      .capability-card { grid-template-columns:1fr; }
      .capability-card-actions { align-items:center; }
    }

@media (max-width: 620px) {
      .identity-fields { grid-template-columns: 1fr; }
      .identity-field.wide { grid-column: auto; }
    }

@media (max-width: 900px) {
      body.dm-chat-open .floating-dm-directory { left: 12px; width: 270px; }
      .chat-room { left: 294px; right: 12px; width: auto; }
    }

@media (max-width: 680px) {
      body.dm-chat-open .floating-dm-directory {
        left: 10px; right: 10px; top: 10px; bottom: auto; width: auto; height: min(42vh, 360px);
      }
      .chat-room { left: 10px; right: 10px; top: calc(min(42vh, 360px) + 20px); bottom: 10px; width: auto; padding: 14px; }
      .chat-heading h3 { font-size: 17px; }
    }

@media (max-width:680px) {
      .schedule-form { padding:16px; border-radius:17px; }
      .schedule-grid { grid-template-columns:1fr; }
      .schedule-field.wide { grid-column:auto; }
      .schedule-actions { align-items:flex-start; flex-direction:column; }
      .schedule-submit { width:100%; }
    }

@media (max-width:680px) {
      .resident-log-dialog.diary-mode { width:100vw !important; }
      .diary-library { display:block; min-height:0; border:0; background:transparent; overflow:visible; }
      .diary-index { display:flex; gap:7px; padding:2px 0 13px; border:0; background:transparent; overflow-x:auto; }
      .diary-index-label { display:none; }
      .diary-index-button { flex:0 0 auto; width:auto; min-width:112px; margin:0; padding:9px 11px; border-color:var(--line); }
      .diary-reader { max-height:62dvh; border:1px solid var(--line); border-radius:18px; background:rgba(250,248,241,.72); }
      .diary-page { padding:28px 22px 38px; }
      .diary-page h4 { font-size:23px; margin-bottom:20px; }
      .diary-page-body { font-size:15px; line-height:1.85; }
    }

@media (max-width:680px) { .knowledge-draft-grid { grid-template-columns:1fr; } .knowledge-draft-field.wide { grid-column:auto; } .knowledge-draft-actions { align-items:flex-start; flex-direction:column; } }

@media (max-width:680px) { .cognition-step { grid-template-columns:1fr; gap:4px; } }

@media (max-width: 680px) {
      main { padding: 34px 18px 64px; }
      .event-top { display: grid; }
      .event-badges { justify-content: flex-start; }
      .event-meta { grid-template-columns: 1fr; }
      .event-details dl { grid-template-columns: 1fr; gap: 3px; }
      .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    }

@media (max-width:760px) {
      .resident-console { grid-template-columns:1fr; }
      .resident-sidebar { position:static; }
      .resident-list { grid-template-columns:repeat(2,minmax(0,1fr)); }
      .chat-thread { min-height:280px; }
    }

@media (max-width:620px) {
    .resident-home-banner { grid-template-columns:1fr; }
    .home-settings-button { justify-self:start; }
  }

@media (max-width: 680px) {
    body { min-height:100dvh; }
    main { width:100%; padding:22px 16px max(30px,env(safe-area-inset-bottom)); overflow:hidden; }
    h1 { font-size:27px; letter-spacing:-.025em; }
    .subtitle { font-size:13px; }
    .status-row { margin-top:17px; gap:8px; }
    .live,.deploy-button,.auth-button { font-size:11px; padding:6px 10px; }
    .time { margin-top:22px; font-size:18px; }
    .tabs { margin-top:26px; padding-bottom:12px; position:sticky; top:0; z-index:8;
      background:color-mix(in srgb,var(--paper) 94%,transparent); backdrop-filter:blur(16px); }
    .tab { flex:1; min-height:40px; }
    h2 { margin-top:22px; font-size:12px; }
    .event-heading { align-items:center; }
    .event-toolbar { flex-wrap:nowrap; overflow-x:auto; padding-bottom:3px; scrollbar-width:none; }
    .event-toolbar::-webkit-scrollbar { display:none; }
    .event-filter { flex:0 0 auto; min-height:36px; }
    .event-card summary { padding:15px; }
    .event-summary { font-size:12px; }
    .resident-section-head { align-items:center; }
    .resident-section-head h2 { margin:22px 0 0; }
    .system-credential-button { margin-top:18px; font-size:11px; padding:7px 11px; }
    .resident-console { display:block; margin-top:14px; }
    .resident-sidebar { position:static; padding:10px; border-radius:18px; }
    .resident-sidebar-title { margin:2px 4px 9px; }
    .resident-list { grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; }
    .resident-select { min-height:112px; padding:12px; border-color:var(--line); background:rgba(255,255,255,.34); }
    .resident-select[aria-selected="true"] { background:rgba(218,242,231,.8); border-color:#b9d0c0; }
    .resident-select .home-door { font-size:9px; }
    .resident-select .home-appellation { font-size:14px; line-height:1.35; }
    .resident-stage { margin-top:12px; }
    .resident-home-banner { padding:17px; border-radius:18px; gap:12px; }
    .resident-home-name { font-size:21px; }
    .resident-card { padding:18px !important; border-radius:18px !important; }
    .resident-head { gap:12px; }
    .resident-name { font-size:21px !important; }
    .presence-strip { padding:14px !important; }
    .metrics { gap:8px; }
    .metric { padding:12px 8px !important; }
    .metric-value { font-size:20px !important; }
    .resident-actions { display:grid !important; grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px !important; }
    .resident-actions button { width:100%; min-height:43px; margin:0 !important; padding:9px !important; }
    .resident-actions .talk-button { grid-column:1/-1; background:var(--ink); color:var(--paper); border-color:var(--ink); }
    .chat-room { display:flex; flex-direction:column; height:calc(100dvh - 176px); min-height:520px;
      border:0 !important; background:transparent !important; }
    .chat-heading { flex:0 0 auto; align-items:flex-start !important; gap:10px !important; padding:4px 0 12px; }
    .chat-heading h3 { margin:7px 0 0 !important; font-size:18px !important; line-height:1.35; }
    .chat-back { flex:0 0 auto; padding:8px 11px !important; }
    .chat-thread { flex:1 1 auto; height:auto; min-height:0; padding:12px 6px 18px !important;
      border:1px solid var(--line); border-radius:20px; background:rgba(255,255,255,.32); }
    .chat-bubble { max-width:88% !important; padding:13px 14px !important; font-size:15px; line-height:1.6; }
    .chat-composer { flex:0 0 auto; display:grid !important; grid-template-columns:minmax(0,1fr) auto;
      gap:8px !important; padding-top:10px; background:var(--paper); }
    .chat-input { min-height:58px !important; max-height:132px; padding:13px !important; border-radius:17px !important;
      font-size:16px !important; resize:none; }
    .chat-send { min-width:58px; min-height:58px; padding:10px !important; border-radius:17px !important; }
    .chat-note { flex:0 0 auto; margin:7px 2px 0; font-size:10px; line-height:1.45; }
    .identity-dialog,#homeDialog,#capabilityDialog,#credentialDialog,#loginDialog {
      width:100vw !important; max-width:none !important; max-height:92dvh !important; margin:auto 0 0 !important;
      border-radius:24px 24px 0 0 !important; border:0 !important;
    }
    .identity-dialog::backdrop,#homeDialog::backdrop,#capabilityDialog::backdrop,
    #credentialDialog::backdrop,#loginDialog::backdrop { background:rgba(33,35,31,.38); backdrop-filter:blur(5px); }
    .identity-form,#homeDialog .identity-form,#capabilityDialog .identity-form,#loginDialog .identity-form {
      padding:24px 18px max(24px,env(safe-area-inset-bottom)) !important;
    }
    .identity-fields { grid-template-columns:1fr !important; }
    .identity-full,.identity-field.wide { grid-column:auto !important; }
    .capability-heading { align-items:flex-start; }
    .capability-add { padding:8px 12px; }
    .capability-card { grid-template-columns:1fr; }
    .capability-card-actions { justify-content:flex-start; }
    #loginDialog { margin:auto !important; width:calc(100vw - 28px) !important; border-radius:24px !important; }
  }

@media (max-width:640px) {
    .batch-management-list {
      display: grid;
      gap: 12px;
      margin: 20px 0;
    }

    .batch-management-item {
      display: grid;
      gap: 5px;
      width: 100%;
      padding: 16px 18px;
      text-align: left;
      color: var(--ink);
      background: #f1f5f0;
      border: 1px solid #d8e3d9;
      border-radius: 16px;
      cursor: pointer;
    }

    .batch-management-item:hover,
    .batch-management-item:focus-visible {
      background: #e5efe7;
      border-color: #9fb8a7;
    }

    .batch-management-item strong { font-size: 16px; }
    .batch-management-item span { color: var(--muted); font-size: 13px; }

    .thinking-provision-grid { grid-template-columns:1fr; }
    .thinking-resident-choice { grid-template-columns:auto 1fr; }
    .thinking-resident-choice .batch-preview-code { grid-column:2; }
  }

@media(max-width:760px){
      .world-current-hero{grid-template-columns:1fr; min-height:auto; padding:28px 22px 58px}
      .world-resident-orbit{width:140px;height:140px}
      .world-resident-orbit strong{font-size:42px}
      .world-metrics{grid-template-columns:repeat(2,1fr)}
      .world-stream-row{grid-template-columns:74px 12px minmax(0,1fr)}
      .world-stream-category{display:none}
    }

@media(max-width:720px){.funds-body{grid-template-columns:1fr}.funds-pie{width:220px}.funds-shell{padding:20px}}

@media (max-width:680px) {
      body.world-home-game .time {grid-template-columns:1fr;align-items:start;}
      body.world-home-game .time::before,
      body.world-home-game .emct-readable,
      body.world-home-game .emct-subline {grid-column:1;}
      body.world-home-game .time::before {grid-row:1;}
      body.world-home-game .emct-readable {grid-row:2;}
      body.world-home-game .emct-subline {grid-row:3;}
    }

@media (max-width:900px) {
      body.world-home-game main{padding:22px 18px 64px}
      body.world-home-game .status-row{align-items:flex-start}
      body.world-home-game .world-view-controls{width:100%;margin-left:0;order:3;flex-wrap:wrap}
      body.world-home-game .auth-button{margin-left:auto}
      body.world-home-game .world-current-hero{grid-template-columns:1fr;min-height:0;padding:48px 24px 30px}
      body.world-home-game .world-current-hero h2{font-size:clamp(52px,13vw,92px)}
      body.world-home-game .world-resident-orbit{width:100%;min-height:170px;margin-top:30px;aspect-ratio:auto}
      body.world-home-game .world-metrics{grid-template-columns:repeat(2,minmax(0,1fr))}
      body.world-home-game .world-stream-row{grid-template-columns:90px 14px minmax(0,1fr);padding:18px}
      body.world-home-game .world-stream-category{grid-column:3;justify-self:start}
    }

@media (max-width:560px) {
      body.world-home-game h1{font-size:31px}
      body.world-home-game .tabs{display:flex;width:100%}
      body.world-home-game .tab{flex:1;min-width:0;padding:11px 8px}
      body.world-home-game .world-current-hero{clip-path:polygon(0 0,calc(100% - 20px) 0,100% 20px,100% 100%,20px 100%,0 calc(100% - 20px))}
      body.world-home-game .world-current-hero h2{margin-top:32px;font-size:49px;line-height:.84}
      body.world-home-game .world-metrics{grid-template-columns:1fr}
      body.world-home-game .world-metric{min-height:130px}
      body.world-home-game .world-stream-row{grid-template-columns:12px minmax(0,1fr);gap:14px}
      body.world-home-game .world-stream-row time{grid-column:2;font-size:11px}
      body.world-home-game .world-stream-node{grid-row:1/4}
      body.world-home-game .world-stream-category{grid-column:2}
    }

@media(max-width:900px){
      body.world-home-game .resident-console{grid-template-columns:1fr}
      body.world-home-game .resident-sidebar{position:static;box-shadow:6px 6px 0 var(--game-pink)}
      body.world-home-game .resident-universe-members{max-height:260px;overflow:auto}
      body.world-home-game .chat-message{max-width:92%}
    }

@media(max-width:560px){
      body.world-home-game dialog{width:calc(100vw - 18px);max-width:none}
      body.world-home-game .event-heading,
      body.world-home-game .resident-section-head{padding:12px}
      body.world-home-game .resident-home-banner,
      body.world-home-game .resident-card{box-shadow:6px 6px 0 var(--game-black)}
      body.world-home-game .chat-heading{padding:10px}
      body.world-home-game .chat-message{max-width:96%}
    }

@media(max-width:760px){
      body.world-home-game #batchToolsDialog .batch-management-list{grid-template-columns:1fr}
      body.world-home-game #batchToolsDialog .batch-management-item{min-height:112px}
    }

@media(max-width:560px){
      body.world-home-game #releaseApprovalDialog[open]{width:calc(100vw - 18px);max-height:92vh}
    }

@media(max-width:900px){
      body.world-home-game .world-view-controls{margin-left:0}
      body.world-home-game .status-row>.world-style-toggle{margin-left:auto!important}
      body.world-home-game .status-row>.auth-button{margin-left:0!important}
    }

@media(max-width:620px){
      body.world-home-game .world-view-controls{width:auto;order:initial}
      body.world-home-game .status-row>.world-style-toggle{margin-left:0!important}
      body.world-home-game .status-row>.auth-button{margin-left:auto!important}
    }

@media(max-width:700px){
      body.world-home-game .world-current-hero h2{font-size:clamp(46px,12vw,72px);line-height:.98}
      body.world-home-game #worldDaysTail{font-size:.65em}
    }

@media(max-width:620px){
      body.world-home-game .identity-form{padding:22px 20px 20px}
      body.world-home-game .identity-form>.identity-fields{row-gap:15px}
    }

@media(max-width:680px){
      body.world-home-game .chat-room>.chat-heading {
        width:calc(100% + 24px);margin:-12px -12px 14px;padding:14px 12px;
      }
    }

@media(max-width:760px){
      body.world-home-game .world-current-hero h2 {font-size:clamp(48px,15vw,76px)!important;line-height:.86!important;}
      body.world-home-game .world-current-hero #worldDaysTail {font-size:.58em!important;}
    }

@media(max-width:760px){
      body.world-home-game .world-current-hero h2 {
        font-size:clamp(48px,14vw,72px)!important;
        line-height:.9!important;
        text-shadow:3px 3px 0 var(--game-pink)!important;
      }
      body.world-home-game .world-current-hero #worldDaysAlive {font-size:.72em!important;}
      body.world-home-game .world-current-hero #worldDaysTail {font-size:.43em!important;}
      html[lang="zh-Hant"] body.world-home-game .world-current-hero #worldDaysTail {font-size:.39em!important;}
    }

@media(max-width:680px){
      body.world-home-game.world-home-dark .chat-room {
        height:calc(100dvh - 20px)!important;
        max-height:calc(100dvh - 20px)!important;
        grid-template-rows:auto minmax(240px,1fr) auto auto!important;
      }
    }

@media(max-width:620px){
      body.world-home-game.world-home-dark #hallDialog .hall-toolbar {
        grid-template-columns:1fr!important;
      }
    }

@media (max-width:760px) {
    body.world-home-game .intention-ledger .intention-entry > div {
      grid-template-columns:minmax(0,1fr) !important;
    }
    body.world-home-game .intention-ledger .intention-entry > div > * {
      grid-column:1 !important;
    }
  }

@media (max-width:520px) {
    body.world-home-game .chat-message.owner,
    body.world-home-game .chat-message.sent {
      min-width:172px !important;
    }
  }

@media (max-width:640px) {
    .earth-mirror-brand-logo,
    body.world-home-game .earth-mirror-brand-logo { width:52px; height:52px; }
  }

@media(max-width:680px){.task-read-toolbar,.task-quest-card{grid-template-columns:1fr}.task-read-all,.task-read-one{width:100%}}

@media (max-width: 720px) {
    .resident-completion-toast { right: 16px; bottom: 16px; }
  }
