/* ================================
   core.css
   FINAL REPLACEMENT VERSION
   - Common header / layout / cards / buttons / forms / footer
   - Page-local CSS must not redefine typography
   - Text styles live only here
================================ */

/* =================================================
   Design Tokens
================================================= */
:root{
  --bg:#f6f8fb;
  --surface:#ffffff;
  --text:#0f172a;
  --muted:#64748b;
  --border:#e5e7eb;

  --navy:#0b3552;
  --navy-2:#0f4a72;
  --link:#1d4ed8;

  --orange:#f97316;
  --accent-brown:#b45309;
  --accent-brown-soft:rgba(180,83,9,.35);
  --accent-brown-bg:rgba(255,248,235,.85);

  --radius:10px;
  --radius-sm:10px;

  --shadow:0 10px 30px rgba(2,8,23,.06);
  --shadow-sm:0 6px 18px rgba(2,8,23,.06);

  /* layout */
  --rail:260px;
  --gap:22px;

  /* page widths */
  --main-home:1060px;
  --main-default:1060px;

  /* paddings */
  --content-padding-x:48px;
  --content-padding-x-mobile:16px;
  --content-pad-l:var(--content-padding-x);
  --content-pad-r:var(--content-padding-x);

  /* header */
  --header-h:48px;
  --header-gutter:16px;

  /* buttons/icons */
  --btn-h:30px;
  --page-icon-size:74px;
  --avatar-size:40px;

  /* page-head spacing */
  --ph-mb:10px;
  --ph-next-mt:0px;

  /* weekend colors */
  --cal-sun:#ef4444;
  --cal-sat:#1d4ed8;

  /* typography */
  --font-sans:"Noto Sans JP", system-ui, -apple-system, "Segoe UI", sans-serif;

  --fs-1:28px;
  --fs-2:20px;
  --fs-3:14px;
  --fs-4:14px;
  --fs-5:12px;
  --fs-6:12px;

  --fw-1:900;
  --fw-2:800;
  --fw-3:800;
  --fw-4:400;
  --fw-5:400;
  --fw-6:400;

  --lh-1:1.25;
  --lh-2:1.30;
  --lh-3:1.30;
  --lh-4:1.70;
  --lh-5:1.50;
  --lh-6:1.40;

  --c-text:var(--text);
  --c-muted:var(--muted);
  --c-link:var(--link);
  --c-accent:var(--navy);
  --c-inverse:#ffffff;
  --c-orange:var(--orange);
}

/* =================================================
   Base Reset
================================================= */
*{ box-sizing:border-box; }

html,
body{ height:100%; }

body{
  margin:0;
  padding-top:var(--header-h);
  background:var(--bg);
  color:var(--c-text);
  font-family:var(--font-sans);
  font-size:var(--fs-4);
  font-weight:var(--fw-4);
  line-height:var(--lh-4);
}

img{
  max-width:100%;
  height:auto;
  display:block;
}

a{
  color:var(--c-link);
  text-decoration:none;
}

a:hover{ text-decoration:underline; }

a.btn:hover,
a.btn:focus-visible{ text-decoration:none; }

h1,h2,h3{
  margin:0;
  line-height:inherit;
}

p{ margin:12px 0; }

/* -------------------------------------------------
   Form element UA diff guard
------------------------------------------------- */
button,
input,
textarea,
select{
  font:inherit;
  color:inherit;
}

button{
  appearance:none;
  -webkit-appearance:none;
  background:transparent;
}


/* =================================================
   Page mode variables
================================================= */
body.page-default{
  --main-max:var(--main-default);
  --layout-max:calc(var(--main-max) + var(--rail) + var(--gap));
  --top-gap:0px;

  /* asymmetric padding */
  --content-pad-l:72px;
  --content-pad-r:18px;
}

body.page-home{
  --main-max:var(--main-home);
  --layout-max:calc(var(--main-max) + var(--rail) + var(--gap));
  --top-gap:-12px;
}


/* =================================================
   Header (fixed)
================================================= */
.site-header{
  position:fixed;
  top:0;
  left:0;
  right:0;
  z-index:2000;

  background:var(--surface);
  border-bottom:2px solid var(--navy);
}

.site-header :is(.l-header__inner, .header-row){
  width:100%;
  height:var(--header-h);
  max-width:none;
  min-width:0;
  margin:0;
  padding:0 16px;

  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
}

.site-header :is(.nav, nav, .header-actions){
  margin-left:auto;
  min-width:0;

  display:flex;
  align-items:center;
  gap:10px;
}

.site-header img{
  max-height:36px;
  width:auto;
  height:auto;
  object-fit:contain;
}

.site-header :is(.brand img, .logo img, a img){
  max-width:260px;
}


/* =================================================
   Global Layout (2-column)
================================================= */
main.layout{
  width:min(var(--layout-max), calc(100% - 32px));
  margin:0 auto 26px;
  margin-top:var(--top-gap, 0px);

  display:grid;
  grid-template-columns:minmax(0,1fr) var(--rail);
  gap:var(--gap);
  align-items:start;
}

.left-section,
.right-section{
  min-width:0;
}

.right-section{
  display:flex;
  flex-direction:column;
  gap:14px;
}


/* =================================================
   LEFT column core frame
================================================= */
body.page-default .left-section{ display:block; }

body.page-default .left-section > .page-content.l-content,
body.page-home .left-section > .page-content.l-content{
  width:100%;
  max-width:var(--main-max);
  margin:0 auto;
}

body.page-default .left-section > .page-content.l-content{
  padding-left:var(--content-pad-l);
  padding-right:var(--content-pad-r);
  box-sizing:border-box;
}

body.page-home .left-section > .page-content.l-content{
  padding-left:0;
  padding-right:0;
}

/* nested .page-content guard */
body.page-default .left-section .page-content:not(.l-content){
  max-width:none;
  margin-left:0;
  margin-right:0;
  padding-left:0;
  padding-right:0;
}

.page-content{
  padding-top:0;
  display:flow-root;
}

.page-content > :first-child{
  margin-top:0;
}


/* =================================================
   Page Head (structure only)
================================================= */
.page-head{
  display:flex;
  align-items:center;
  gap:12px;
  margin:0 0 20px;
}

body:not(.page-home) .page-head{
  margin-bottom:var(--ph-mb);
}

body:not(.page-home) .page-head + *{
  margin-top:var(--ph-next-mt);
}

body:not(.page-home) :is(
  .page-head + .page-content > :first-child,
  .page-head + .page-inner > :first-child,
  .page-head + .card > :first-child,
  .page-head + .panel > :first-child,
  .page-head + .box > :first-child,
  .page-head + .widget > :first-child
){
  margin-top:0;
}

.page-head .ph-icon{
  width:var(--page-icon-size);
  height:var(--page-icon-size);
  overflow:hidden;
  border-radius:50%;
  border:1px solid var(--border);
  background:#fff;
}

.page-head .ph-icon img{
  width:100%;
  height:100%;
  object-fit:cover;
}


/* =================================================
   Card System
================================================= */
.card,
.rr-block,
.panel,
.box,
.widget,
.dash-card{
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:var(--radius);
  box-shadow:var(--shadow-sm);
  min-width:0;
}

.card{
  padding:16px;
}

.rr-block,
.panel,
.box,
.widget,
.dash-card{
  padding:10px;
}

.card--sm{
  padding:12px;
  border-radius:var(--radius-sm);
}

.card--padless{ padding:0; }
.card-pad{ padding:16px; }


/* =================================================
   Avatar (global)
================================================= */
img.avt,
a > img.avt{
  width:var(--avatar-size);
  height:var(--avatar-size);
}

img.avt{
  max-width:var(--avatar-size);
  max-height:var(--avatar-size);
  display:block;
  flex-shrink:0;
  border-radius:50%;
  object-fit:cover;
}


/* =================================================
   Buttons (global)
================================================= */
.btn{
  height:var(--btn-h);
  padding:0 16px;

  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;

  border:1px solid transparent;
  border-radius:var(--radius);
  background:transparent;
  color:var(--c-text);
  cursor:pointer;
  user-select:none;
  white-space:nowrap;

  font-weight:700;
  line-height:1;
}

.btn-md{
  height:var(--btn-h);
  padding:0 16px;
  font-size:14px;
}

.btn-sm{
  height:32px;
  padding:0 12px;
  border-radius:var(--radius);
  font-size:12px;
}

.btn:disabled,
.btn[aria-disabled="true"]{
  opacity:.55;
  cursor:not-allowed;
}

.btn:focus-visible{
  outline:2px solid rgba(29,78,216,.35);
  outline-offset:2px;
}

.btn-primary{
  background:var(--navy);
  color:#fff;
}

.btn-primary:hover{
  background:var(--navy-2);
}

.btn-secondary{
  background:#fff;
  color:var(--navy);
  border-color:rgba(11,53,82,.45);
}

.btn-secondary:hover{
  background:var(--navy);
  border-color:var(--navy);
  color:#fff;
}

.btn-ghost{
  background:rgba(15,23,42,.04);
  border-color:rgba(15,23,42,.10);
  color:var(--c-text);
}

.btn-ghost:hover{
  background:rgba(15,23,42,.10);
  border-color:rgba(15,23,42,.18);
}


/* =================================================
   Actions row (global)
================================================= */
.actions{
  margin-top:10px;

  display:flex;
  align-items:center;
  gap:10px;
  flex-wrap:wrap;
}

.actions .left-actions,
.actions .right-actions{
  display:flex;
  align-items:center;
  gap:10px;
  flex-wrap:wrap;
}

.actions .right-actions{
  margin-left:auto;
}


/* =================================================
   Forms (structure only)
================================================= */
label{
  display:block;
  margin-bottom:6px;
  font-weight:900;
}

input,
textarea,
select{
  width:100%;
  padding:6px 14px;
  border:1px solid var(--border);
  border-radius:var(--radius);
}

textarea{
  min-height:24px;
}


/* =================================================
   Right Rail
================================================= */
.right-section,
.rr-block{
  min-width:0;
}

/* flatpickr overflow safety */
.right-section :is(
  .flatpickr-calendar,
  .flatpickr-innerContainer,
  .flatpickr-rContainer,
  .flatpickr-days
){
  width:100%;
  max-width:100%;
  box-sizing:border-box;
}

/* 7 columns */
.right-section .flatpickr-weekdays{
  width:100%;
  box-sizing:border-box;
}

.right-section .flatpickr-weekday{
  flex:1 1 0;
  max-width:calc(100% / 7);
}

.right-section .dayContainer{
  width:100%;
  min-width:0;
  max-width:100%;
  box-sizing:border-box;

  display:flex;
  flex-wrap:wrap;
}

.right-section .flatpickr-day{
  flex:0 0 calc(100% / 7);
  max-width:calc(100% / 7);
  box-sizing:border-box;
}


/* =================================================
   Weekend colors (Sun / Sat)
================================================= */
.right-section .flatpickr-weekday:nth-child(1){
  color:var(--cal-sun);
  font-weight:800;
}

.right-section .flatpickr-weekday:nth-child(7){
  color:var(--cal-sat);
  font-weight:800;
}

.right-section .flatpickr-day:nth-child(7n + 1){
  color:var(--cal-sun);
}

.right-section .flatpickr-day:nth-child(7n){
  color:var(--cal-sat);
}

.right-section :is(
  .flatpickr-day.prevMonthDay,
  .flatpickr-day.nextMonthDay,
  .flatpickr-day.flatpickr-disabled
){
  color:rgba(100,116,139,.45);
}

.right-section :is(
  .flatpickr-day.selected,
  .flatpickr-day.startRange,
  .flatpickr-day.endRange,
  .flatpickr-day.inRange
){
  color:#fff;
}

.right-section :is(
  .flatpickr-day.selected:nth-child(7n + 1),
  .flatpickr-day.startRange:nth-child(7n + 1),
  .flatpickr-day.endRange:nth-child(7n + 1)
){
  background:var(--cal-sun);
  border-color:var(--cal-sun);
}

.right-section :is(
  .flatpickr-day.selected:nth-child(7n),
  .flatpickr-day.startRange:nth-child(7n),
  .flatpickr-day.endRange:nth-child(7n)
){
  background:var(--cal-sat);
  border-color:var(--cal-sat);
}

.right-section :is(
  .flatpickr-day.prevMonthDay.selected,
  .flatpickr-day.nextMonthDay.selected,
  .flatpickr-day.flatpickr-disabled.selected
){
  background:transparent;
  border-color:transparent;
  color:rgba(100,116,139,.45);
}

.right-section .flatpickr-day.today{
  font-weight:800;
}


/* =================================================
   HOME Right Rail – pack top
================================================= */
body.page-home .right-section > :first-child{
  margin-top:0;
}

body.page-home .right-section > :first-child.rr-block{
  padding:10px;
}

body.page-home .right-section > :first-child .rr-title{
  margin-bottom:6px;
}

body.page-home .right-section :is(#date-time, .date-time){
  margin:0 0 6px;
  padding:0;
  line-height:1.2;
}

body.page-home .right-section :is(
  .flatpickr-calendar,
  .flatpickr-innerContainer,
  .flatpickr-months,
  .flatpickr-rContainer
){
  margin-top:0;
  padding-top:0;
}


/* =================================================
   Footer
================================================= */
:is(
  body > footer.footer,
  body > footer.l-footer,
  body > footer.footer.l-footer,
  footer.footer,
  footer.l-footer,
  footer.footer.l-footer
){
  margin:0;
  padding:2px 0;
  height:auto;
  min-height:0;

  background:var(--navy);
  border-top:1px solid rgba(255,255,255,.12);
}

:is(
  body > footer.footer .container,
  body > footer.footer .l-container,
  body > footer.l-footer .container,
  body > footer.l-footer .l-container,
  footer.footer .container,
  footer.footer .l-container,
  footer.l-footer .container,
  footer.l-footer .l-container,
  footer.footer.l-footer .container,
  footer.footer.l-footer .l-container
){
  width:min(var(--layout-max), calc(100% - 32px));
  min-width:0;
  margin:0 auto;
  padding:0;

  display:flex;
  align-items:center;
  justify-content:center;
}

:is(
  body > footer.footer p,
  body > footer.footer small,
  body > footer.footer div,
  body > footer.l-footer p,
  body > footer.l-footer small,
  body > footer.l-footer div,
  footer.footer p,
  footer.footer small,
  footer.footer div,
  footer.l-footer p,
  footer.l-footer small,
  footer.l-footer div
){
  margin:0;
}


/* =================================================
   FAQ
================================================= */
#faq-panel{
  position:fixed;
  right:18px;
  bottom:96px;
  z-index:9999;

  width:min(360px, calc(100vw - 36px));
  display:none;
  flex-direction:column;

  background:#fff;
  border-radius:var(--radius);
}

#faq-panel.is-open{
  display:flex;
}

.faq-launcher{
  position:fixed;
  right:18px;
  bottom:18px;

  width:72px;
  height:72px;
  border:0;
  border-radius:999px;
  background:#0b4f8a;
  color:#fff;
  cursor:pointer;
}


/* =================================================
   Utility
================================================= */
.page-inner{
  max-width:var(--main-max);
  margin:0 auto;
}


/* =================================================
   Responsive
================================================= */
@media (max-width:980px){
  main.layout{
    width:calc(100% - 24px);
    grid-template-columns:1fr;
  }

  body.page-default{
    --content-pad-l:var(--content-padding-x-mobile);
    --content-pad-r:var(--content-padding-x-mobile);
  }

  body.page-default .left-section > .page-content.l-content{
    max-width:100%;
    padding-left:var(--content-pad-l);
    padding-right:var(--content-pad-r);
  }

  body.page-home .left-section > .page-content.l-content{
    padding-left:0;
    padding-right:0;
  }
}

@media (max-width:720px){
  :root{ --header-h:56px; }

  .site-header img{
    max-height:36px;
  }

  .site-header :is(.brand img, .logo img, a img){
    max-width:200px;
  }
}


/* =================================================
   Typography (GLOBAL) – 6 sizes / 6 colors
================================================= */
.t-h1{
  font-size:var(--fs-1);
  font-weight:var(--fw-1);
  line-height:var(--lh-1);
}

.t-h2{
  font-size:var(--fs-2);
  font-weight:var(--fw-2);
  line-height:var(--lh-2);
}

.t-h3{
  font-size:var(--fs-3);
  font-weight:var(--fw-3);
  line-height:var(--lh-3);
}

.t-body{
  font-size:var(--fs-4);
  font-weight:var(--fw-4);
  line-height:var(--lh-4);
}

.t-meta{
  font-size:var(--fs-5);
  font-weight:var(--fw-5);
  line-height:var(--lh-5);
}

.t-small{
  font-size:var(--fs-6);
  font-weight:var(--fw-6);
  line-height:var(--lh-6);
}

.c-text{ color:var(--c-text); }
.c-muted{ color:var(--c-muted); }
.c-link{ color:var(--c-link); }
.c-accent{ color:var(--c-accent); }
.c-inverse{ color:var(--c-inverse); }
.c-orange{ color:var(--c-orange); }


/* =================================================
   Legacy aliases
================================================= */
.small{
  font-size:var(--fs-6);
  font-weight:var(--fw-6);
  line-height:var(--lh-6);
  color:var(--c-muted);
}

.ph-title{
  font-size:var(--fs-2);
  font-weight:var(--fw-1);
  line-height:var(--lh-1);
}

.ph-sub{
  font-size:var(--fs-5);
  font-weight:var(--fw-5);
  line-height:var(--lh-5);
  color:var(--c-muted);
}

.rr-title{
  font-size:var(--fs-3);
  font-weight:var(--fw-3);
  line-height:var(--lh-3);
}

.rr-body{
  font-size:var(--fs-6);
  font-weight:var(--fw-6);
  line-height:var(--lh-6);
  color:var(--c-text);
}