/* ==========================================================================
   UI-Kit Styles (iOS-artig). Alle Farben nur ueber Tokens aus base.css,
   damit Hell/Dunkel und Akzentfarbe automatisch passen.
   ========================================================================== */

/* ---------------- App-Icon ---------------- */
.ph-app-icon {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    overflow: hidden;
    box-shadow: inset 0 0 0 .5px rgba(255, 255, 255, .12), 0 1px 2px rgba(0, 0, 0, .18);
}
.ph-app-icon::after {       /* dezenter Glanz oben */
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(255, 255, 255, .18) 0%, rgba(255, 255, 255, 0) 46%);
    pointer-events: none;
}
.ph-app-icon .ph-icon { filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .12)); }
.ph-app-icon-svg, .ph-app-icon-svg svg { width: 100%; height: 100%; }

/* ---------------- Bild ---------------- */
.ph-img { position: relative; overflow: hidden; background: var(--fill3); width: 100%; height: 100%; }
.ph-img img { width: 100%; height: 100%; display: block; opacity: 0; transition: opacity .25s; }
.ph-img.loaded { background: transparent; }
.ph-img.loaded img { opacity: 1; }
.ph-img:not(.loaded):not(.failed)::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(100deg, transparent 20%, rgba(255, 255, 255, .06) 50%, transparent 80%);
    background-size: 200% 100%;
    animation: ph-shimmer 1.2s linear infinite;
}
.ph-img-broken { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); color: var(--label3); }
@keyframes ph-shimmer { from { background-position: 150% 0; } to { background-position: -50% 0; } }

/* ---------------- Avatar ---------------- */
.ph-avatar { position: relative; flex: 0 0 auto; border-radius: 50%; overflow: hidden; }
.ph-avatar .ph-img { border-radius: 50%; }
.ph-avatar-fallback {
    width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 600; letter-spacing: .01em;
}
.ph-avatar-fallback .ph-icon { opacity: .92; }

/* ---------------- Stack-Navigation ---------------- */
.ph-stack { position: absolute; inset: 0; overflow: hidden; }
.ph-stack-page {
    position: absolute;
    inset: 0;
    background: var(--bg);
    transition: transform .34s var(--ease-out), opacity .34s var(--ease-out);
    will-change: transform;
}
.ph-stack-page.under { transform: translateX(-28%); }
.ph-stack-page.under::after {
    content: ''; position: absolute; inset: 0; background: #000; opacity: .18; pointer-events: none;
}
.ph-stack-page.buried { display: none; }
.ph-stack-page.entering { transform: translateX(100%); transition: none; }
.ph-stack-page.leaving { transform: translateX(100%); pointer-events: none; }
.ph-stack-page.under-restoring { transform: translateX(0); }
.ph-stack-page.under-restoring::after { opacity: 0; transition: opacity .34s; }
.ph-stack-page.top { box-shadow: -8px 0 24px rgba(0, 0, 0, .18); }

/* ---------------- Seite / Nav-Leiste ---------------- */
.ph-page {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    color: var(--label);
    --tint: var(--accent);
}
.ph-page.grouped { background: var(--bg-grouped); }
.ph-bar {
    flex: 0 0 auto;
    padding-top: 54px;
    position: relative;
    z-index: 5;
    background: transparent;
    transition: background .2s;
}
.ph-bar::after {
    content: '';
    position: absolute;
    left: 0; right: 0; bottom: 0;
    height: .5px;
    background: var(--sep);
    opacity: 0;
    transition: opacity .2s;
}
.ph-bar.scrolled { background: var(--bar); }
.ph-bar.scrolled::after { opacity: 1; }
.ph-bar.transparent, .ph-bar.transparent.scrolled { background: transparent; }
.ph-bar.transparent::after { display: none; }
.ph-bar-row {
    height: 44px;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 0 8px;
}
.ph-bar-left, .ph-bar-right { display: flex; align-items: center; gap: 4px; min-width: 0; }
.ph-bar-right { justify-content: flex-end; padding-right: 8px; }
.ph-bar-right .ph-link, .ph-bar-right .ph-icon-btn { color: var(--tint); }
.ph-bar-title {
    font-size: 17px; font-weight: 600; text-align: center;
    max-width: 210px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
    opacity: 0; transition: opacity .18s;
}
.ph-bar-title.show { opacity: 1; }
.ph-back {
    display: flex; align-items: center;
    color: var(--tint);
    font-size: 17px;
    margin-left: -6px;
    height: 44px;
    max-width: 150px;
}
.ph-back span { margin-left: -3px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.ph-back:active, .ph-link:active, .ph-icon-btn:active { opacity: .45; }
.ph-link { color: var(--tint, var(--accent)); font-size: 17px; padding: 8px 6px; }
.ph-link.bold { font-weight: 600; }
.ph-link:disabled { color: var(--label3); }
.ph-icon-btn {
    width: 36px; height: 36px;
    display: inline-flex; align-items: center; justify-content: center;
    color: var(--tint, var(--accent));
    border-radius: 50%;
}
.ph-icon-btn.circle { background: var(--fill3); width: 32px; height: 32px; }

.ph-large-title {
    font-size: 34px;
    font-weight: 700;
    letter-spacing: -.024em;
    line-height: 41px;
    padding: 2px 16px 8px;
}
.ph-page-body { flex: 1 1 auto; min-height: 0; position: relative; padding-bottom: 36px; }
.ph-page.has-footer .ph-page-body { padding-bottom: 12px; }
.ph-page-footer { flex: 0 0 auto; position: relative; z-index: 5; }

/* ---------------- Listen ---------------- */
.ph-list-wrap { margin: 0 16px 34px; }
.ph-list-wrap.plain { margin: 0 0 24px; }
.ph-list-header {
    font-size: 13px; color: var(--label2); text-transform: uppercase; letter-spacing: .02em;
    padding: 0 16px 7px;
}
.ph-list-footer { font-size: 13px; color: var(--label2); padding: 7px 16px 0; line-height: 1.35; }
.ph-list { background: var(--bg-elev); border-radius: 12px; overflow: hidden; }
.ph-list-wrap.plain .ph-list { border-radius: 0; background: transparent; }
.ph-page:not(.grouped) .ph-list-wrap:not(.plain) .ph-list { background: var(--bg-elev); }

.ph-row {
    display: flex;
    align-items: center;
    min-height: 44px;
    padding-left: 16px;
    position: relative;
    background: transparent;
    transition: background .12s;
}
.ph-row.clickable:active { background: var(--fill2); }
.ph-row.disabled { opacity: .45; }
.ph-row-icon {
    width: 30px; height: 30px; border-radius: 7px;
    display: flex; align-items: center; justify-content: center;
    margin-right: 14px; flex: 0 0 auto;
}
.ph-row .ph-avatar { margin-right: 12px; }
.ph-row-main {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: center;
    align-self: stretch;
    padding: 10px 16px 10px 0;
    position: relative;
}
.ph-row + .ph-row .ph-row-main::before,
.ph-swipe + .ph-swipe .ph-row-main::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: .5px;
    background: var(--sep);
}
.ph-row-text { flex: 1 1 auto; min-width: 0; }
.ph-row-title { font-size: 17px; line-height: 22px; }
.ph-row-sub { font-size: 14px; color: var(--label2); line-height: 19px; margin-top: 1px; }
.ph-row.has-avatar .ph-row-title { font-weight: 500; }
.ph-row.danger .ph-row-title { color: var(--red); }
.ph-row.accent .ph-row-title { color: var(--accent); }
.ph-row-right { display: flex; align-items: center; gap: 6px; margin-left: 10px; flex: 0 0 auto; }
.ph-row-value { color: var(--label2); font-size: 17px; max-width: 170px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.ph-row-chev { color: var(--label3); margin-right: -4px; }
.ph-row-check { color: var(--accent); }

/* Wisch-Zeile */
.ph-swipe { position: relative; overflow: hidden; background: var(--bg-elev); }
.ph-list-wrap.plain .ph-swipe, .ph-page:not(.grouped) .ph-list-wrap.plain .ph-swipe { background: var(--bg); }
.ph-swipe-actions { position: absolute; right: 0; top: 0; bottom: 0; display: flex; visibility: hidden; }
.ph-swipe.revealing .ph-swipe-actions { visibility: visible; }
.ph-swipe-actions button {
    flex: 1; color: #fff; font-size: 13px; font-weight: 500;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
}
.ph-swipe-content { position: relative; background: inherit; transition: transform .28s var(--ease-out); touch-action: pan-y; }
.ph-swipe-content.dragging { transition: none; }

/* ---------------- Formular ---------------- */
.ph-toggle {
    width: 51px; height: 31px; border-radius: 16px;
    background: var(--fill);
    position: relative;
    transition: background .22s;
    flex: 0 0 auto;
}
.ph-toggle span {
    position: absolute; top: 2px; left: 2px;
    width: 27px; height: 27px; border-radius: 50%;
    background: #fff;
    box-shadow: 0 3px 8px rgba(0, 0, 0, .15), 0 1px 1px rgba(0, 0, 0, .16);
    transition: transform .26s var(--spring);
}
.ph-toggle.on { background: var(--green); }
.ph-toggle.on span { transform: translateX(20px); }
.ph-toggle.disabled { opacity: .5; }

.ph-seg {
    position: relative;
    display: grid;
    grid-template-columns: repeat(var(--n), 1fr);
    height: 32px;
    padding: 2px;
    border-radius: 9px;
    background: var(--fill3);
}
.ph-seg-thumb {
    position: absolute;
    top: 2px; bottom: 2px; left: 2px;
    width: calc((100% - 4px) / var(--n));
    transform: translateX(calc(var(--i) * 100%));
    border-radius: 7px;
    background: var(--bg-elev3);
    box-shadow: 0 3px 8px rgba(0, 0, 0, .12), 0 0 0 .5px rgba(0, 0, 0, .04);
    transition: transform .28s var(--ease-out);
}
.theme-light .ph-seg-thumb { background: #fff; }
.ph-seg button { position: relative; font-size: 13px; font-weight: 500; color: var(--label); z-index: 1; }
.ph-seg button.on { font-weight: 600; }

.ph-btn {
    --btn: var(--accent);
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    font-weight: 600;
    white-space: nowrap;
    transition: opacity .15s, transform .15s;
}
.ph-btn:active { opacity: .7; transform: scale(.98); }
.ph-btn.disabled { opacity: .4; pointer-events: none; }
.ph-btn.block { display: flex; width: 100%; }
.ph-btn.s-sm { height: 30px; padding: 0 14px; border-radius: 15px; font-size: 15px; }
.ph-btn.s-md { height: 36px; padding: 0 16px; border-radius: 10px; font-size: 16px; }
.ph-btn.s-lg { height: 50px; padding: 0 20px; border-radius: 14px; font-size: 17px; }
.ph-btn.k-filled { background: var(--btn); color: #fff; }
.ph-btn.k-tinted { background: var(--btn-tint, var(--accent-tint)); color: var(--btn); }
.ph-btn.k-gray { background: var(--fill2); color: var(--btn); }
.ph-btn.k-plain { color: var(--btn); padding-left: 6px; padding-right: 6px; }
.ph-btn.k-danger { background: rgba(255, 69, 58, .16); color: var(--red); }
.ph-btn.k-white { background: #fff; color: #000; }

.ph-input {
    display: flex;
    align-items: center;
    position: relative;
    background: var(--bg-elev);
    border-radius: 12px;
    padding: 0 12px;
    min-height: 44px;
    gap: 8px;
}
.ph-page:not(.grouped) .ph-input { background: var(--fill3); }
.ph-input-label { color: var(--label2); font-size: 15px; min-width: 70px; }
.ph-input-icon { color: var(--label2); flex: 0 0 auto; }
.ph-input input, .ph-input textarea {
    flex: 1 1 auto; min-width: 0;
    background: transparent; border: 0; outline: none;
    font-size: 17px; color: var(--label);
    padding: 11px 0;
    resize: none;
    line-height: 22px;
}
.ph-input input::placeholder, .ph-input textarea::placeholder, .ph-search input::placeholder { color: var(--label3); }
.ph-input.multiline { align-items: flex-start; }
.ph-input-clear {
    width: 18px; height: 18px; border-radius: 50%;
    background: var(--label3); color: var(--bg-elev);
    display: flex; align-items: center; justify-content: center;
    flex: 0 0 auto;
}

.ph-search {
    display: flex; align-items: center; gap: 6px;
    height: 36px; border-radius: 10px;
    background: var(--fill3);
    padding: 0 8px;
    color: var(--label2);
    margin: 0 16px 12px;
}
.ph-search input { flex: 1; min-width: 0; background: transparent; border: 0; outline: none; font-size: 17px; color: var(--label); }

.ph-chip {
    display: inline-flex; align-items: center; gap: 5px;
    height: 32px; padding: 0 13px;
    border-radius: 16px;
    background: var(--fill3);
    color: var(--label);
    font-size: 15px; font-weight: 500;
    white-space: nowrap;
}
.ph-chip.active { background: var(--label); color: var(--bg); }

.ph-slider { display: flex; align-items: center; gap: 12px; padding: 12px 16px; }
.ph-slider-icon { color: var(--label2); flex: 0 0 auto; }
.ph-slider-track { position: relative; flex: 1; height: 28px; cursor: pointer; }
.ph-slider-track::before { content: ''; position: absolute; left: 0; right: 0; top: 12px; height: 4px; border-radius: 2px; background: var(--fill); }
.ph-slider-fill { position: absolute; left: 0; top: 12px; height: 4px; border-radius: 2px; background: var(--accent); }
.ph-slider-knob {
    position: absolute; top: 0; width: 28px; height: 28px; margin-left: -14px; border-radius: 50%;
    background: #fff; box-shadow: 0 3px 8px rgba(0, 0, 0, .18), 0 0 0 .5px rgba(0, 0, 0, .06);
}

/* ---------------- Tabbar ---------------- */
.ph-tabbar {
    display: flex;
    height: 83px;
    padding-bottom: 32px;
    background: var(--bar);
    border-top: .5px solid var(--sep);
}
.ph-tabbar button {
    flex: 1;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    color: var(--label3);
    padding-top: 3px;
}
.theme-dark .ph-tabbar button { color: rgba(235, 235, 245, .42); }
.ph-tabbar button.on { color: var(--accent); }
.ph-tab-icon { position: relative; }
.ph-tab-icon .ph-badge { position: absolute; top: -4px; left: 16px; }
.ph-tab-label { font-size: 10px; font-weight: 500; letter-spacing: .01em; }

/* ---------------- Sheet ---------------- */
.ph-sheet-wrap {
    position: absolute; inset: 0;
    background: rgba(0, 0, 0, .42);
    z-index: 60;
    display: flex; align-items: flex-end;
    pointer-events: auto;
}
.ph-sheet {
    width: 100%;
    background: var(--sheet);
    border-radius: 14px 14px 0 0;
    display: flex; flex-direction: column;
    box-shadow: 0 -8px 30px rgba(0, 0, 0, .3);
    overflow: hidden;
    color: var(--label);
    --bg-grouped: var(--sheet);
}
.theme-dark .ph-sheet { --bg-elev: #2c2c2e; }
.ph-sheet.h-large { height: calc(100% - 64px); }
.ph-sheet.h-medium { height: 56%; }
.ph-sheet.h-auto { max-height: calc(100% - 64px); }
.ph-sheet-grab { width: 36px; height: 5px; border-radius: 3px; background: var(--label4); margin: 6px auto 0; flex: 0 0 auto; }
.ph-sheet-head {
    display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
    height: 50px; padding: 0 10px; flex: 0 0 auto;
}
.ph-sheet-title { font-size: 17px; font-weight: 600; text-align: center; }
.ph-sheet-side { display: flex; }
.ph-sheet-side.right { justify-content: flex-end; }
.ph-sheet-body { flex: 1 1 auto; min-height: 0; padding: 8px 0 34px; }
.ph-sheet.h-auto .ph-sheet-body { flex: 0 1 auto; }

.ph-sheet-enter-active, .ph-sheet-leave-active { transition: background .32s; }
.ph-sheet-enter-active .ph-sheet, .ph-sheet-leave-active .ph-sheet { transition: transform .36s var(--ease-out); }
.ph-sheet-enter-from, .ph-sheet-leave-to { background: rgba(0, 0, 0, 0); }
.ph-sheet-enter-from .ph-sheet, .ph-sheet-leave-to .ph-sheet { transform: translateY(100%); }

/* ---------------- Kleinteile ---------------- */
.ph-spinner { position: relative; display: inline-block; color: var(--label2); }
.ph-spinner i {
    position: absolute; left: 46%; top: 0;
    width: 8%; height: 28%;
    border-radius: 2px;
    background: currentColor;
    transform-origin: 50% 178%;
    animation: ph-spin-fade .8s linear infinite;
}
@keyframes ph-spin-fade { from { opacity: 1; } to { opacity: .15; } }
.ph-badge {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 20px; height: 20px; padding: 0 6px;
    border-radius: 10px;
    background: var(--red); color: #fff;
    font-size: 13px; font-weight: 600; line-height: 1;
}
.ph-empty {
    display: flex; flex-direction: column; align-items: center; text-align: center;
    padding: 70px 36px 30px;
    gap: 6px;
}
.ph-empty-icon {
    width: 72px; height: 72px; border-radius: 50%;
    background: var(--fill3); color: var(--label2);
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 10px;
}
.ph-empty-title { font-size: 20px; font-weight: 700; }
.ph-empty-text { font-size: 15px; color: var(--label2); line-height: 1.4; }
.ph-empty .ph-btn { margin-top: 14px; }
.ph-loading { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 60px 0; color: var(--label2); font-size: 15px; }
.ph-card { background: var(--bg-elev); border-radius: 14px; }
.ph-card.pad { padding: 16px; }
.ph-time { font-variant-numeric: tabular-nums; }
.ph-section-title { font-size: 22px; font-weight: 700; letter-spacing: -.02em; padding: 0 16px 10px; }
.ph-hstack { display: flex; gap: 10px; align-items: center; }
.ph-pad { padding: 0 16px; }
.ph-gap { height: 20px; }
