/* 手机 9:16 布局。仅 html.layout-phone 生效，PC 版样式不受影响。 */

html.layout-phone {
    -webkit-text-size-adjust: 100%;
}

html.layout-phone body {
    padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
}

html.layout-phone .btn {
    padding: 0.4rem 0.75rem;
}

html.layout-phone .btn-sm {
    padding: 0.32rem 0.55rem;
    font-size: 0.82rem;
}

html.layout-phone .card-header {
    padding: 0.7rem 0.85rem;
}

html.layout-phone .card-body {
    padding: 0.85rem;
}

html.layout-phone .container-fluid.mt-4 {
    margin-top: 0.75rem !important;
    padding-left: 0.75rem;
    padding-right: 0.75rem;
}

/* 顶栏：只留品牌、用户名、退出 */
html.layout-phone .navbar {
    position: sticky;
    top: 0;
    z-index: 1030;
    padding-top: env(safe-area-inset-top, 0px);
}

html.layout-phone .navbar .navbar-nav {
    display: none !important;
}

html.layout-phone .navbar-brand {
    font-size: 1.1rem;
    margin-right: 0.5rem;
}

html.layout-phone .navbar .container-fluid {
    flex-wrap: nowrap;
}

html.layout-phone .navbar .d-flex.align-items-center {
    gap: 0.4rem !important;
    flex-shrink: 0;
}

html.layout-phone .navbar .btn {
    padding: 0.2rem 0.55rem;
    font-size: 0.75rem;
    white-space: nowrap;
}

html.layout-phone #navUserName {
    max-width: 7rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 底栏 */
.phone-tabbar {
    display: none;
}

html.layout-phone .phone-tabbar {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1060;
    height: calc(56px + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: #fff;
    border-top: 1px solid #dee2e6;
}

html.layout-phone .phone-tabbar button {
    flex: 1;
    border: 0;
    background: transparent;
    color: #6c757d;
    font-size: 0.72rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 56px;
}

html.layout-phone .phone-tabbar button i {
    font-size: 1.15rem;
    line-height: 1;
}

html.layout-phone .phone-tabbar button.active {
    color: #0d6efd;
    font-weight: 600;
}

html.layout-phone.butler-open .phone-tabbar {
    display: none;
}

html.layout-phone .butler-fab {
    display: none;
}

html.layout-phone .hud-toast {
    left: 0.75rem;
    right: 0.75rem;
    bottom: calc(72px + env(safe-area-inset-bottom, 0px));
    max-width: none;
}

html.layout-phone.butler-open .hud-toast {
    bottom: 1rem;
}

/* 角色条 */
html.layout-phone .character-hud {
    position: sticky;
    top: calc(48px + env(safe-area-inset-top, 0px));
    padding: 0.55rem 0.7rem;
    margin-bottom: 0.7rem;
    font-size: 0.82rem;
}

html.layout-phone .character-hud .d-flex {
    gap: 0.45rem 0.7rem !important;
}

html.layout-phone .character-hud .flex-grow-1 {
    min-width: 100% !important;
    flex-basis: 100%;
}

/* 计划台标题 + 查看谁 */
html.layout-phone .page-heading {
    flex-direction: column;
    align-items: stretch !important;
    gap: 0.5rem;
}

html.layout-phone .page-heading h2 {
    font-size: 1.25rem;
}

html.layout-phone .page-heading label {
    display: none;
}

html.layout-phone #ownerBadge {
    display: none;
}

html.layout-phone .page-heading .form-select {
    width: 100% !important;
}

/* 视图标签横向滑动 */
html.layout-phone .view-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 0.75rem !important;
    scrollbar-width: none;
}

html.layout-phone .view-tabs::-webkit-scrollbar {
    display: none;
}

html.layout-phone .view-tabs .nav-item {
    flex: 0 0 auto;
}

html.layout-phone .view-tabs .nav-link {
    padding: 0.45rem 0.65rem;
    font-size: 0.8rem;
    white-space: nowrap;
}

html.layout-phone .toolbar-header {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0.55rem;
}

html.layout-phone .toolbar-header h5 {
    font-size: 1rem;
}

html.layout-phone .toolbar-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

html.layout-phone .toolbar-actions .btn {
    margin: 0 !important;
    flex: 1 1 auto;
}

html.layout-phone .daily-stats .col-6 {
    padding: 0.2rem;
}

html.layout-phone .daily-stats .card-body {
    padding: 0.55rem 0.3rem;
}

html.layout-phone .daily-stats h4 {
    font-size: 1.15rem;
}

/* 日历：格子只显示日期和任务数 */
html.layout-phone .dow-full { display: none; }
html.layout-phone .dow-short { display: inline; }
.dow-short { display: none; }

html.layout-phone .calendar-day {
    min-height: 48px;
    padding: 3px 2px;
    font-size: 0.72rem;
    cursor: pointer;
}

html.layout-phone .calendar-day .task-list {
    display: none;
}

html.layout-phone .calendar-day .btn-link {
    display: none;
}

html.layout-phone .day-count {
    display: inline-block;
    min-width: 1.1rem;
    text-align: center;
    font-size: 0.65rem;
    color: #0d6efd;
    font-weight: 600;
}

.day-count { display: none; }

html.layout-phone .calendar-dow {
    font-size: 0.75rem;
    margin-bottom: 0.25rem !important;
}

/* 周视图改成上下堆叠的日卡片（col-md 在窄屏已是整行） */
html.layout-phone #weekViewContainer .card-header {
    padding: 0.5rem 0.7rem;
}

/* 管家全屏 */
html.layout-phone .butler-panel {
    inset: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    max-height: none;
    border-radius: 0;
    z-index: 1085;
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

html.layout-phone #butlerInput {
    font-size: 16px;
}

/* 弹窗必须盖住底栏，否则保存按钮会被挡住 */
html.layout-phone .modal-backdrop {
    z-index: 1088;
}

html.layout-phone .modal {
    z-index: 1090;
}

html.layout-phone .modal-dialog {
    margin: 0;
    max-width: 100%;
    min-height: 100%;
}

html.layout-phone .modal-content {
    min-height: 100dvh;
    border-radius: 0;
}

html.layout-phone .modal-footer {
    position: sticky;
    bottom: 0;
    background: #fff;
    padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
}

html.layout-phone .modal-dialog.modal-lg {
    max-width: 100%;
}

html.layout-phone input,
html.layout-phone select,
html.layout-phone textarea {
    font-size: 16px;
}

html.layout-phone .table {
    font-size: 0.82rem;
}

html.layout-phone #socialSurface h2,
html.layout-phone #characterSurface h2 {
    font-size: 1.25rem;
}

html.layout-phone .auth-card {
    padding: 1.25rem;
    max-width: 100%;
}
