body {
    background:#0f172a;
    color:#e2e8f0;
    font-family:-apple-system,Segoe UI,sans-serif;
    padding:20px;
    margin:0;
}

.layout {
    display:flex;
    gap:20px;
    max-width:1200px;
    margin:auto;
}

.menu-toggle {
    display:none;
    position:fixed;
    top:15px;
    left:15px;
    z-index:9999;
    background:#1b2435;
    color:#e2e8f0;
    border:1px solid rgba(148,163,184,0.35);
    padding:10px 14px;
    border-radius:10px;
    font-size:16px;
}

.menu {
    width:260px;
    background:#0b1220;
    border-radius:14px;
    padding:16px;
    border:1px solid rgba(148,163,184,0.35);
    position:sticky;
    top:20px;
    align-self:flex-start;
    z-index:50;
}

.logo {
    font-size:20px;
    font-weight:600;
    color:#94a3b8;
    text-align:center;
    margin-bottom:14px;
    letter-spacing:1px;
    opacity:0.85;
}

.menu a {
    display:block;
    padding:12px;
    margin:6px 0;
    background:#1e293b;
    border-radius:10px;
    color:#e2e8f0;
    text-decoration:none;
    border:1px solid rgba(148,163,184,0.3);
    transition:0.15s;
    text-align:left;
}

.menu a:hover {
    background:#334155;
}

.content-area {
    flex:1;
    position:relative;
}

/* Карточки */
.card {
    display:flex;
    flex-direction:column;
    align-items:center;
    gap:18px;
    background:#0b1220;
    border-radius:18px;
    padding:16px;
    border:1px solid rgba(148,163,184,0.35);
    box-shadow:0 18px 40px rgba(0,0,0,0.6);

    width:100%;          /* 🔥 фикс для телефонов */
    box-sizing:border-box; /* 🔥 чтобы padding не ломал ширину */
}

.portrait-img {
    width:100%;
    max-width:640px;
    border-radius:14px;
    display:block;
    margin:0 auto;
    object-fit:cover;
}

.portraitv-img {
    width:100%;
    max-width:1000px;
    border-radius:14px;
    display:block;
    margin:0 auto;
    object-fit:cover;
}

/* Основной текст */
.content {
    text-align:left;
    white-space:pre-line;
    font-size:18px;
    line-height:1.45;
    margin:0 !important;
    padding:0 !important;

    width:100%;          /* всегда на всю ширину карточки */
    align-self:stretch;  /* растягиваем внутри flex-карточки */
}

/* 🔥 FIX: убираем отступ, вызванный переносом строки */
#content > .content {
    white-space:normal !important;
}

/* Убираем верхний отступ у первого элемента в карточке */
.card > .content > *:first-child {
    margin-top:0 !important;
    padding-top:0 !important;
}

/* Убираем верхний отступ у первого элемента */
#content > .content > *:first-child {
    margin-top:0 !important;
    padding-top:0 !important;
}

/* Убираем встроенные отступы у медиа */
#content > .content > video:first-child,
#content > .content > img:first-child,
#content > .content > iframe:first-child {
    margin-top:0 !important;
    padding-top:0 !important;
    display:block;
}

/* Убираем отступы у текстовых элементов */
#content > .content > h1:first-child,
#content > .content > h2:first-child,
#content > .content > h3:first-child,
#content > .content > p:first-child,
#content > .content > div:first-child {
    margin-top:0 !important;
    padding-top:0 !important;
}

.name { font-size:27px; font-weight:700; }
.subtitle { font-size:14px; color:#9ca3af; }

.content a {
    color:#38bdf8;
    font-weight:600;
    text-decoration:none;
    border-bottom:1px solid rgba(56,189,248,0.4);
    padding-bottom:2px;
    transition:0.2s;
}

.content a:hover {
    color:#7dd3fc;
    border-bottom-color:#7dd3fc;
}

.btn {
    display:flex;
    align-items:center;
    justify-content:flex-start;
    height:48px;
    padding:0 14px;
    margin:8px 0;
    background:#1e293b;
    border-radius:10px;
    text-align:left;
    color:#e2e8f0;
    text-decoration:none;
    font-size:16px;
    border:1px solid rgba(148,163,184,0.3);
    transition:0.15s;
}

.btn:hover {
    background:#334155;
}

@media (max-width: 800px) {
    .layout { flex-direction:column; }
    .menu { display:none; width:100%; position:relative; top:0; left:0; }
    .menu.open { display:block; }
    .menu-toggle { display:block; }
}

.album {
    display:flex;
    flex-direction:column;
    align-items:center;
    gap:20px;
    width:100%;
}

.album img {
    width:100%;
    max-width:1000px;
    height:auto;
    object-fit:contain;
    border-radius:14px;
    box-shadow:0 0 18px rgba(0,0,0,0.55);
    display:block;
}

/* 🔥 ВИДЕО НИЖЕ — НЕ ПРИМЫКАЕТ К РАМКЕ */
.card > video.portrait-img,
.card > .portrait {
    margin-top:16px !important;
}

.vcontent {
    white-space:normal !important;
    line-height:1.3 !important;
}

.vtitle {
    margin-top:20px !important;
    padding-top:0 !important;
}

.card .vcontent > .vtitle {
    margin-top:20px !important;
}

#content .vcontent .album.video video {
    margin-top:20px !important;
}

.btn {
    cursor:pointer;
}

.name.vtitle {
    margin-bottom: 16px;
}

/* ===== СТИЛИ ТАБЛИЦЫ МЕНДЕЛЕЕВА ===== */

.ptable-content table {
    border-collapse: collapse;
    margin: 10px auto;
    background: #ffffff;
    color: #000000;
    font-size: 14px;
    min-width: 950px;
}

.ptable-content th,
.ptable-content td {
    border: 1px solid #000;
    padding: 6px 4px;
    text-align: center;
    vertical-align: middle;
}

.ptable-content th.group {
    background: #e5e5e5;
    font-weight: bold;
    font-size: 15px;
}

.ptable-content td.period {
    background: #f2f2f2;
    font-weight: bold;
    font-size: 15px;
    width: 40px;
}

.ptable-content td.cell {
    min-width: 90px;
    min-height: 90px;
    padding: 6px;
}

.ptable-content .el {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
    align-items: center;
}

.ptable-content .el .num {
    font-weight: bold;
    font-size: 12px;
}

.ptable-content .el .sym {
    font-size: 20px;
    font-weight: bold;
    margin: 3px 0;
}

.ptable-content .el .name {
    font-size: 11px;
    text-align: center;
    margin: 2px 0;
}

.ptable-content .el .name .ru {
    font-weight: 600;
}

.ptable-content .el .name .lat {
    font-style: italic;
    opacity: 0.8;
}

.ptable-content .el .conf {
    font-size: 11px;
    margin: 2px 0;
}

.ptable-content .el .mass {
    font-size: 11px;
    margin-top: 2px;
}

.ptable-content .nonmetal .sym { color: #d60000; }
.ptable-content .amphoteric .sym { color: #008000; }
.ptable-content .basic .sym { color: #000000; }
.ptable-content .noble .sym { color: #0033cc; }

.ptable-content td.cell:hover {
    background: #f7f7f7;
}

/* ===== ПОДОКНО ===== */

#ptable-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    display: none;
    z-index: 2000;
}

.ptable-window {
    position: absolute;
    top: 40px;
    left: 50%;
    transform: translateX(-50%);
    width: min(95vw, 1600px);
    max-height: calc(100vh - 80px);
    background: #fff;
    border: 1px solid #000;
    box-shadow: 0 0 10px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
}

.ptable-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 10px;
    border-bottom: 1px solid #000;
    font-weight: bold;
    background: #f0f0f0;
    color:#000;
}

.ptable-header button {
    border: none;
    background: #c00;
    color: #fff;
    font-size: 16px;
    width: 26px;
    height: 26px;
    cursor: pointer;
}

.ptable-content {
    padding: 10px;
    overflow: auto;
    background:#fff;
    color:#000;
}

#ptable-overlay {
    display:none;
}

/* ===== Genshin Impact ===== */

.menu.calc-mode {
    position: fixed;
    top: 20px;
    left: 20px;
    height: 100vh;
    width: 260px;
    z-index: 10000;
    overflow-y: auto;
}

#frame {
    display: none;
    position: fixed;
    top: 0;
    left: 330px;
    width: calc(100vw - 350px);
    height: 100vh;
    border: none;
    z-index: 9999;
}

.portraitv-img {
    width:100%;
    max-width:1000px;
    border-radius:14px;
    display:block;
    margin:0 auto;
    object-fit:cover;
}

.vcontent {
    white-space:normal !important;
    line-height:1.3 !important;
}

.vtitle {
    margin-top:20px !important;
    padding-top:0 !important;
}

.name.vtitle {
    margin-bottom: 16px;
}

#content .vcontent .album.video video {
    margin-top:20px !important;
}

.album img {
    max-width:1000px;
}

.btn {
    cursor:pointer;
}

/* Custom emoji */
.emoji {
  width:2.5em;
  height:2.5em;
  vertical-align:middle;
}
