/* ===== Theme ===== */
:root {
  --bg:#0e0f12;
  --card:#161922;
  --panel:#11131a;
  --fg:#e8ecf1;
  --muted:#95a1b2;

  --accent:#6ea8ff;
  --accent-strong:#4a86f7;

  --ok:#45d07b;
  --warn:#ff7a5c;

  --red:#ff697a;      /* 日曜/祝日 */
  --blue:#59a7ff;     /* 土曜 */

  /* カテゴリ色 */
  --c-featured:#47e0c2;
  --c-mokomichi:#a97cff;
  --c-univ:#59a7ff;
  --c-club:#45d07b;
  --c-admin:#ffae51;
}

/* ===== Reset ===== */
* { box-sizing:border-box; }
html,body { height:100%; }
body.portal {
  margin:0;
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.wrap { max-width: 1280px; margin: 0 auto; padding: 0 24px; }

/* ===== Topbar（フルブリード背景と中身の分離） ===== */
.topbar-outer{
  background: linear-gradient(180deg, rgba(78,95,255,.18), rgba(0,0,0,0));
  border-bottom: 1px solid rgba(255,255,255,.08);
  width: 100%;
}
.topbar{
  background: transparent;
  border-bottom: none;
  display:grid; grid-template-columns: 1fr auto auto; gap:24px; align-items:center;
  padding: 18px 0 8px;
}
.topbar .left { display:flex; flex-direction:column; gap:6px; }
.topbar h1 { margin:0; font-size: 44px; font-weight: 900; line-height: 1; letter-spacing:.02em; }
.datebox { display:flex; align-items:baseline; gap:8px; }
.ymd { font-size: 56px; font-weight: 900; letter-spacing: .5px; }
.youbi { font-size: 38px; font-weight: 800; color: var(--fg); }
.youbi.day-red { color: var(--red); }
.youbi.day-blue { color: var(--blue); }
.clock { font-size: 40px; font-weight: 900; letter-spacing: .5px; color:#ffffffd9; text-shadow: 0 0 20px rgba(110,168,255,.25); }
.top-actions { display:flex; gap:10px; }
.chip {
  display:inline-flex; align-items:center; gap:8px; padding:10px 14px;
  border-radius:12px; background: #23283a; color:#e9eef8; cursor:pointer;
  border:1px solid rgba(255,255,255,.08);
}
.chip:hover { background:#2a3147; }
.chip.warn { background: rgba(255,122,92,.12); color:#ffd5cc; border-color: rgba(255,122,92,.25); }
.chip.accent { background: rgba(110,168,255,.16); color:#dbe8ff; border-color: rgba(110,168,255,.32); }

/* ===== Section title ===== */
.sec-title { font-size: 14px; letter-spacing: .20em; font-weight: 900; margin: 12px 0 10px; color:#9fb0ca; }

/* ===== Monitor ===== */
.monitor { display:grid; grid-template-columns: 1fr auto; align-items:center; gap: 24px; }
.monitor-row { display:grid; grid-template-columns: repeat(5, minmax(160px, 1fr)); gap: 18px; }
.stat { background: var(--panel); border:1px solid rgba(255,255,255,.06); border-radius:14px; padding:12px 14px; display:flex; flex-direction:column; gap:8px; min-height: 80px; }
.stat-label { font-size:12px; color:#8ea0bc; letter-spacing:.22em; }
.stat-value { font-size:28px; font-weight:900; line-height:1; color:#eef3ff; text-shadow:0 0 14px rgba(122,163,255,.12); }
.stat .unit { font-size:18px; font-weight:700; color:#9fb0ca; margin-left:6px; }

/* ===== CPU Ring ===== */
.ring-card { display:flex; align-items:center; gap:18px; justify-self:end; }
.ring {
  width: 260px; height: 260px; border-radius: 50%;
  background: conic-gradient(var(--accent) var(--p,0deg), rgba(255,255,255,.08) 0deg);
  box-shadow: 0 0 20px rgba(110,168,255,.25), inset 0 0 30px rgba(110,168,255,.12);
  position: relative;
}
.ring-hole { position:absolute; inset:22px; background:var(--bg); border-radius:50%; box-shadow: inset 0 0 18px rgba(0,0,0,.4); }
.ring-label { position:absolute; inset:0; display:grid; place-items:center; font-size:44px; font-weight:900; color:#eaf1ff; }

/* ===== Buttons ===== */
.btn { border:none; background: linear-gradient(180deg, var(--accent), var(--accent-strong)); color:#051024; padding:10px 16px; border-radius:12px; cursor:pointer; font-weight:900; }
.btn:hover { filter:brightness(1.05); }
.btn.small { padding:6px 10px; font-size:13px; }
.btn.ghost { background:#283047; color:#dbe4f6; }

/* ===== 2カラム（左=TODO / 右=リンク） ===== */
.twocols { display:grid; grid-template-columns: 1fr 1fr; gap:24px; align-items:stretch; }
.col-left, .col-right { min-width:0; display:flex; flex-direction:column; }
.spacer { flex:1; }

/* ===== TODO ===== */
.todo-head { display:flex; align-items:center; gap:10px; }
.todo-form {
  background: var(--panel); border:1px solid rgba(255,255,255,.06);
  border-radius:14px; padding:14px; margin-top:8px;
}
.todo-form.hidden { display:none; }
.frow { display:flex; flex-direction:column; gap:6px; margin-bottom:10px; }
.frow2 { display:flex; gap:16px; margin-bottom:10px; align-items:end; }
.frow2 .grow { flex:1; }
.req { color:var(--red); margin-left:6px; }
input[type="text"], input[type="date"], textarea {
  width:100%; border:1px solid rgba(255,255,255,.12); background:#0f121a; color:#eaf1ff;
  border-radius:10px; padding:10px 12px; font-size:16px; outline:none;
}
input::placeholder, textarea::placeholder { color:#7c8aa3; }
textarea { resize:vertical; }
.form-actions { display:flex; gap:10px; justify-content:flex-end; }
.todo-subhead { display:flex; align-items:center; gap:12px; margin-top:10px; margin-bottom:12px; }
.muted { color: var(--muted); }

.todo-list { list-style:none; padding:0; margin:0; display:grid; gap:10px; }
.todo-item {
  background: linear-gradient(180deg, #171b27, #10131b); border:1px solid rgba(255,255,255,.06);
  border-radius:14px; padding:12px 14px;
}
.todo-item.done { opacity:.55; text-decoration: line-through; }
.todo-line { display:grid; grid-template-columns: 1fr auto; align-items:center; gap:12px; }
.main .title { font-weight:900; color:#f1f5ff; }
.main .detail { color:#9fb0ca; font-size:13px; margin-top:3px; }
.tail { display:flex; align-items:center; gap:8px; }
.due-badge {
  display:inline-flex; align-items:center; padding:4px 10px; border-radius:999px; font-size:12px;
  background:#242b3f; color:#dbe4f6; border:1px solid rgba(255,255,255,.08);
}
.due-badge.due-over { background:#3b1e29; color:#ffc2cb; border-color:#ff6e86; }
.due-badge.due-today{ background:#3b2b1d; color:#ffdcb3; border-color:#ffae51; }

/* ===== 右カラム（リンク） ===== */
.link-pane {
  overflow: auto;
  max-height: 60vh;          /* 右だけ独立スクロール */
  padding-right: 6px;
}
.link-section { margin-bottom: 18px; }
.link-head {
  font-size:12px; letter-spacing:.22em; font-weight:900; margin: 6px 0 8px;
  color:#c5d3ea;
  position:relative; padding-left:12px;
}
.link-head::before {
  content:''; position:absolute; left:0; top:50%; transform:translateY(-50%);
  width:6px; height:6px; border-radius:50%; background:#7fa0ff;
}
/* カテゴリ色ドット */
.link-section[data-cat="featured"] .link-head::before { background: var(--c-featured); }
.link-section[data-cat="mokomichi"] .link-head::before { background: var(--c-mokomichi); }
.link-section[data-cat="univ"] .link-head::before { background: var(--c-univ); }
.link-section[data-cat="club"] .link-head::before { background: var(--c-club); }
.link-section[data-cat="admin"] .link-head::before { background: var(--c-admin); }

.link-grid { display:grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap:12px; }
.link-card {
  display:block;
  background: linear-gradient(180deg, #171b27, #10131b);
  border:1px solid rgba(255,255,255,.08);
  border-radius:12px; padding:14px 16px;
  font-weight:900; color:#f1f5ff; text-decoration:none;
  box-shadow: 0 10px 16px rgba(0,0,0,.18);
  transition: transform .08s ease-out, box-shadow .12s ease-out, border-color .12s ease-out;
}
.link-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 24px rgba(0,0,0,.28);
  border-color: rgba(110,168,255,.35);
}

/* ===== 小画面レスポンシブ ===== */
@media (max-width: 1024px){
  .monitor { grid-template-columns: 1fr; }
  .ring-card { justify-self:start; }
  .twocols { grid-template-columns: 1fr; }
  .link-grid { grid-template-columns: 1fr; }
  .ymd { font-size: 44px; }
  .youbi { font-size: 30px; }
  .clock { font-size: 34px; }
}
/* ===== Auth (Login) ===== */
body.auth{
  min-height:100dvh;
  margin:0;
  background: var(--bg);
  color: var(--fg);
  display:flex;
  flex-direction:column;
}

.auth-hero-outer{
  background: linear-gradient(180deg, rgba(78,95,255,.18), rgba(0,0,0,0));
  border-bottom: 1px solid rgba(255,255,255,.08);
  width: 100%;
  padding: 32px 0 64px;
}
.auth-hero .brand{
  font-size: 40px;
  font-weight: 900;
  letter-spacing: .02em;
}

.auth-main{ margin-top: -40px; } /* ヒーロー帯に少し食い込ませる */
.auth-card{
  max-width: 520px;
  margin: 0 auto;
  background: rgba(17,19,26,.60);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 18px 40px rgba(0,0,0,.35);
  backdrop-filter: blur(8px);
}
.auth-card h2{ margin:0 0 6px; font-size:28px; font-weight:900; }
.auth-lead{ margin:0 0 14px; color:var(--muted); }

.auth-label{
  display:block; margin:14px 0 6px;
  font-size:13px; letter-spacing:.06em; color:#c5d3ea;
}

.input-wrap{ position:relative; }
.input-wrap input[type="email"],
.input-wrap input[type="password"]{
  width:100%;
  border:1px solid rgba(255,255,255,.12);
  background:#0f121a; color:#eaf1ff;
  border-radius:10px; padding:12px 44px 12px 12px;
  font-size:16px; outline:none;
}
.input-wrap input::placeholder{ color:#7c8aa3; }
.pw-toggle{
  position:absolute; right:8px; top:50%; transform:translateY(-50%);
  width:34px; height:34px; border:none; background:transparent; color:#9fb0ca;
  border-radius:8px; cursor:pointer;
}
.pw-toggle:hover{ background:#1a2030; color:#d8e2fb; }

.auth-actions{ margin-top: 18px; }
.btn.wide{ width:100%; }

.auth-msg{
  margin: 10px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 14px;
  border:1px solid transparent;
}
.auth-msg.error{ background:#341f27; color:#ffd6dd; border-color:#ff6e86; }
.auth-msg.ok{ background:#1d3227; color:#c9ffdb; border-color:#45d07b; }
.hidden{ display:none; }

.auth-links{
  margin-top: 16px;
  display:flex; align-items:center; gap:12px; justify-content:space-between;
}
.text-link{ color:#cde0ff; text-decoration:underline; font-weight:700; }

@media (max-width: 560px){
  .auth-hero-outer{ padding: 24px 0 54px; }
  .auth-main{ margin-top:-30px; }
  .auth-card{ padding:18px; }
  .auth-hero .brand{ font-size:32px; }
}
/* =========================================================
   Mobile (Pixel 8a 〜 幅 ≤ 480px 想定)
   既存スタイルを壊さない最小限の上書き
   ======================================================= */
@media (max-width: 480px) {

  /* セーフエリア（パンチホール/ノッチ対策） */
  :root {
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
  }

  html, body {
    font-size: 16px;   /* iOS/Android の入力時ズーム抑止 */
    -webkit-text-size-adjust: 100%;
  }

  /* コンテンツ幅とパディング調整 */
  .wrap {
    max-width: none;
    padding-left: 16px;
    padding-right: 16px;
  }

  /* ===== Top bar / ヘッダー ===== */
  .topbar-outer {
    padding-top: var(--safe-top);
    /* グラデを端まで伸ばすために余白をゼロに寄せる（既存の背景を活かす） */
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
  }
  .topbar {
    gap: 8px;
  }
  .topbar .left h1 {
    font-size: 1.15rem;
    line-height: 1.3;
    margin: 0 0 2px;
  }
  .datebox .ymd {
    font-size: 3.0rem;
  }
  .datebox .youbi {
    font-size: 2.05rem;
    margin-left: 4px;
  }
  /* 時計は下段に回して左寄せ */
  .clock {
    width: 100%;
    order: 3;
    text-align: left;
    font-size: 2.5rem;
    margin-top: 4px;
  }
  /* ヘッダー右のアクション（ログアウト/やること登録） */
  .top-actions {
    gap: 8px;
  }
  .chip, .btn {
    min-height: 30px;          /* タップターゲット */
    padding: 10px 14px;
    font-size: .95rem;
    border-radius: 10px;
  }

  /* ===== Server Monitor ===== */
  .monitor {
    display: block;
  }
  .monitor-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
  }
  .stat {
    flex: 1 1 calc(50% - 10px); /* 2列並び（幅が足りなければ折返し） */
    min-width: 150px;
    padding: 12px 14px;
    border-radius: 12px;
  }
  .stat-label {
    font-size: .8rem;
    opacity: .8;
  }
  .stat-value {
    font-size: 1.2rem;
  }
  .ring-card {
    margin: 12px auto 0;
  }
  .ring {
    width: 120px;
    height: 120px;
  }
  .ring-label {
    font-size: 1.05rem;
  }

  /* ===== 2カラム → 1カラム ===== */
  .twocols {
    display: block;
  }
  .col-left, .col-right {
    width: 100%;
  }
  .col-right {
    margin-top: 22px;
  }

  /* ===== TODO ===== */
  .todo-head {
    gap: 8px;
  }
  .todo-subhead {
    margin-top: 6px;
  }
  .todo-list {
    gap: 10px;
  }
  .todo-item {
    border-radius: 12px;
    padding: 12px;
  }
  .todo-line {
    gap: 10px;
  }
  .todo-item .title {
    font-size: 1rem;
  }
  .todo-item .detail {
    margin-top: 6px;
    font-size: .95rem;
    line-height: 1.5;
  }
  .due-badge {
    font-size: .8rem;
    padding: 4px 8px;
    border-radius: 999px;
  }
  .complete-btn {
    min-width: 64px;
    min-height: 40px;
    font-size: .95rem;
    border-radius: 10px;
  }

  /* 追加フォーム */
  .todo-form {
    padding: 12px;
    border-radius: 12px;
  }
  .todo-form .frow,
  .todo-form .frow2 {
    gap: 8px;
  }
  .todo-form input[type="text"],
  .todo-form input[type="date"],
  .todo-form textarea {
    font-size: 16px;   /* 入力時ズーム抑止 */
    min-height: 44px;
    border-radius: 10px;
    padding: 10px 12px;
  }
  .todo-form textarea {
    min-height: 96px;
  }
  .form-actions .btn {
    min-width: 44%;
  }

  /* ===== Links（カードを詰めすぎない） ===== */
  .link-section {
    margin-bottom: 18px;
  }
  .link-head {
    font-size: .9rem;
    opacity: .8;
    margin-bottom: 10px;
  }
  .link-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
  }
  .link-card {
    min-height: 44px;
    border-radius: 12px;
    padding: 12px;
    font-size: .95rem;
  }

  /* ===== 認証系（login/register/verify） ===== */
  body.auth .auth-hero-outer {
    padding-top: var(--safe-top);
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
  }
  body.auth .auth-main {
    padding-left: 16px;
    padding-right: 16px;
  }
  body.auth .auth-card {
    margin: 12px auto;
    padding: 18px 16px;
    border-radius: 14px;
  }
  .auth-label {
    font-size: .95rem;
  }
  .auth-form .input-wrap input,
  .auth-form textarea,
  .auth-form select {
    font-size: 16px;
    min-height: 46px;
    border-radius: 10px;
    padding: 10px 12px;
  }
  .auth-actions .btn.wide {
    min-height: 48px;
    font-size: 1rem;
  }

  /* ===== フッター余白（ジェスチャーバー回避） ===== */
  body::after {
    content: "";
    display: block;
    height: var(--safe-bottom);
  }
}
/* =========================================================
   Pixel 8a: ヘッダーのアクションを
   横書き・横長ボタンで時計の下に配置
   ======================================================= */
@media (max-width: 480px) {

  /* ヘッダーを複数行にできるように */
  .topbar {
    display: flex;
    flex-wrap: wrap;     /* ←これが重要 */
    align-items: flex-start;
    gap: 8px;
  }

  /* タイトル＆日付（左ブロック）は1行目いっぱい */
  .topbar .left {
    flex: 1 1 100%;
  }

  /* 時計は2行目いっぱい */
  /* .clock {
    order: 2;
    width: 100%;
    text-align: left;
    font-size: 1.05rem;
    margin-top: 2px;
  } */

  /* アクション（ログアウト / やること登録）は時計の下で横並び */
  .top-actions {
    order: 3;            /* clock の次＝下に来る */
    width: 100%;
    display: flex;
    gap: 10px;
    margin-top: 6px;
  }

  /* デスクトップで縦書きにしている場合の上書き */
  .top-actions .chip {
    writing-mode: horizontal-tb !important; /* 横書きに戻す */
    transform: none !important;             /* もし回転してたら解除 */
    min-height: 20px;                        /* タップしやすい高さ */
    padding: 8px 16px;
    border-radius: 12px;
    font-size: .95rem;
    text-align: center;
    flex: 1 1 0;                             /* 2つを等幅で横並びに */
  }

  /* 端末のノッチ/ジェスチャー対策、左右余白を確保 */
  .topbar-outer {
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
  }
}

/* すごく狭い端末では縦積みに（好みなら不要） */
@media (max-width: 360px) {
  .top-actions {
    flex-direction: column;
  }
}
/* --- Listen Ports --- */
.ports-list { display: grid; gap: 8px; margin-top: 8px; }
.port-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--card-bg, rgba(255,255,255,0.03));
  border: 1px solid var(--line, rgba(255,255,255,0.06));
  border-radius: 12px; padding: 10px 12px;
}
.port-row .addr {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  opacity: .92;
}
.port-row .port { font-weight: 700; }
.port-row .family { margin-left: auto; opacity: .6; font-size: .85rem; }
.chip.small { font-size: .82rem; padding: 4px 8px; }
/* ===== MC Port Planner ===== */
.mcports { background: var(--panel); border:1px solid rgba(255,255,255,.06); border-radius:14px; padding:14px; }
.mcports-controls { display:flex; flex-wrap:wrap; gap:10px; align-items:center; margin-bottom:10px; }
.mcports-controls .seg { display:flex; align-items:center; gap:10px; }
.mcports-controls input[type="number"] { width: 100px; }

.mcports-legend { display:flex; gap:8px; align-items:center; margin-bottom:8px; flex-wrap:wrap; }

.mcports-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
  gap: 8px;
}

.port-chip {
  display:inline-flex; align-items:center; justify-content:center;
  padding: 10px 0; border-radius: 10px; font-weight: 900;
  border: 1px solid rgba(255,255,255,.08);
  background: #1a2030; color:#eaf1ff; cursor: pointer;
}
.port-chip.free     { background: rgba(69,208,123,.08); color:#c7ffdf; border-color: rgba(69,208,123,.35); }
.port-chip.mine     { background: rgba(110,168,255,.16); color:#dbe8ff; border-color: rgba(110,168,255,.40); }
.port-chip.reserved { background: rgba(255,174,81,.14); color:#ffe0b8; border-color: rgba(255,174,81,.35); cursor: not-allowed; }
.port-chip.used     { background: rgba(255,105,122,.14); color:#ffd0d6; border-color: rgba(255,105,122,.35); cursor: not-allowed; }

/* モバイル（Pixel 8a）での並び */
@media (max-width: 480px){
  .mcports-grid { grid-template-columns: repeat(auto-fill, minmax(60px, 1fr)); }
}
