/* ===== Google Fonts ===== */
@import url('https://fonts.googleapis.com/css2?family=DotGothic16&family=M+PLUS+Rounded+1c:wght@400;700&family=Noto+Sans+JP:wght@400;700&family=Yomogi&family=Zen+Kaku+Gothic+New:wght@400;700&display=swap');

/* ===== Dual-Theme Architecture: Material You & Neo-Brutalism ===== */
* { box-sizing: border-box; }
button, input, select, textarea { font-family: inherit; }

:root {
  /* Common Defaults */
  line-height: 1.5em;
  font-family: var(--font-family, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans JP", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif);
  font-size: 16px;
  
  /* Fallback (Material You - Gray) */
  --bg: #f5f5f7;
  --card-bg: #ffffff;
  --primary: #e0e0e0;
  --on-primary: #111111;
  --text: #222222;
  --text-muted: #666666;
  --border-color: #d1d1d6;
  
  --border-radius-card: 24px;
  --border-radius-btn: 99px;
  --border-radius-input: 12px;
  --border-width: 0px;
  --box-shadow: 0 4px 20px rgba(0,0,0,0.05);
  --btn-shadow: none;

  /* Weather colors standard */
  --weather-rain: rgba(0, 120, 215, 0.12);
  --weather-heavy-rain: rgba(0, 120, 215, 0.3);
  --weather-storm: rgba(216, 27, 96, 0.22);
}

/* =========================================
   Fonts (data-font)
   ========================================= */
[data-font="noto"] {
  --font-family: 'Roboto', 'Noto Sans JP', sans-serif;
}
[data-font="mplus"] {
  --font-family: 'Roboto', 'M PLUS Rounded 1c', sans-serif;
}
[data-font="zen"] {
  --font-family: 'Roboto', 'Zen Kaku Gothic New', sans-serif;
}
[data-font="dot"] {
  --font-family: 'DotGothic16', sans-serif;
}
[data-font="yomogi"] {
  --font-family: 'Yomogi', sans-serif;
}
[data-font="system"] {
  --font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans JP", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
}

/* =========================================
   Themes & Colors (data-design / data-color)
   ========================================= */

/* --- Material You Colors --- */
[data-design="material-you"] {
  --border-radius-card: 24px;
  --border-radius-btn: 99px;
  --border-radius-input: 16px;
  --border-width: 0px;
  --box-shadow: 0 4px 24px rgba(0,0,0,0.06);
  --btn-shadow: none;
}
[data-design="material-you"][data-color="sakura"] {
  --bg: #fce4ec; --card-bg: #fff; --primary: #f8bbd0; --on-primary: #880e4f;
  --text: #3e2723; --border-color: #f48fb1;
  --weather-rain: rgba(123, 31, 162, 0.1);
  --weather-heavy-rain: rgba(123, 31, 162, 0.25);
  --weather-storm: rgba(194, 24, 91, 0.28);
}
[data-design="material-you"][data-color="ocean"] {
  --bg: #e3f2fd; --card-bg: #fff; --primary: #90caf9; --on-primary: #0d47a1;
  --text: #1a237e; --border-color: #64b5f6;
  --weather-rain: rgba(13, 71, 161, 0.08);
  --weather-heavy-rain: rgba(13, 71, 161, 0.23);
  --weather-storm: rgba(194, 24, 91, 0.22);
}
[data-design="material-you"][data-color="forest"] {
  --bg: #e8f5e9; --card-bg: #fff; --primary: #a5d6a7; --on-primary: #1b5e20;
  --text: #004d40; --border-color: #81c784;
  --weather-rain: rgba(0, 150, 136, 0.1);
  --weather-heavy-rain: rgba(0, 150, 136, 0.26);
  --weather-storm: rgba(230, 81, 0, 0.22);
}
[data-design="material-you"][data-color="sunset"] {
  --bg: #fff3e0; --card-bg: #fff; --primary: #ffcc80; --on-primary: #e65100;
  --text: #bf360c; --border-color: #ffb74d;
  --weather-rain: rgba(2, 119, 189, 0.1);
  --weather-heavy-rain: rgba(2, 119, 189, 0.26);
  --weather-storm: rgba(183, 28, 28, 0.22);
}
[data-design="material-you"][data-color="gray"] {
  --bg: #f5f5f7; --card-bg: #ffffff; --primary: #e0e0e0; --on-primary: #111111;
  --text: #222222; --border-color: #d1d1d6;
  --weather-rain: rgba(0, 120, 215, 0.12);
  --weather-heavy-rain: rgba(0, 120, 215, 0.3);
  --weather-storm: rgba(216, 27, 96, 0.22);
}
[data-design="material-you"][data-color="purple"] {
  --bg: #f3e5f5; --card-bg: #ffffff; --primary: #e1bee7; --on-primary: #4a148c;
  --text: #31005c; --border-color: #ce93d8;
  --weather-rain: rgba(103, 58, 183, 0.1);
  --weather-heavy-rain: rgba(103, 58, 183, 0.25);
  --weather-storm: rgba(172, 10, 100, 0.25);
}

/* --- Neo-Brutalism --- */
[data-design="neo-brutalism"] {
  --bg: #e0e0e0; /* Darker gray for high contrast against white cards */
  --card-bg: #ffffff;
  --primary: #ffd600; /* Vibrant Yellow */
  --on-primary: #000000;
  --text: #000000;
  --text-muted: #333333;
  --border-color: #000000;
  
  --border-radius-card: 0px;
  --border-radius-btn: 0px;
  --border-radius-input: 0px;
  --border-width: 4px; /* Thicker, bolder borders */
  --box-shadow: 5.6px 5.6px 0px #000000; /* Reduced to 70% */
  --btn-shadow: 4.2px 4.2px 0px #000000; /* Reduced to 70% */

  /* Neo-brutalism weather solid bold colors */
  --weather-rain: #a0e0ff;
  --weather-heavy-rain: #40b0ff;
  --weather-storm: #ff9090;
}

/* Force bold typography for Neo-Brutalism */
[data-design="neo-brutalism"] body,
[data-design="neo-brutalism"] input,
[data-design="neo-brutalism"] select,
[data-design="neo-brutalism"] button,
[data-design="neo-brutalism"] .drawer-link,
[data-design="neo-brutalism"] .select-selected,
[data-design="neo-brutalism"] th,
[data-design="neo-brutalism"] td {
  font-weight: 800;
  letter-spacing: 0.5px;
}


/* =========================================
   Base HTML Elements
   ========================================= */
body {
  background-color: var(--bg);
  color: var(--text);
  margin: 0;
  width: 100% !important;
  max-width: 100% !important;
  padding: 0 8px 20px 8px;
  transition: background-color 0.3s ease, color 0.3s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
}
@media (min-width: 1200px) {
  body {
    padding: 0 150px 20px 150px;
  }
}

h1, h2, h3, h4 { line-height: 1.2em; color: var(--text); }
a { color: var(--text); text-decoration-color: currentColor; }
a:hover { opacity: 0.7; }
img { max-width: 100%; height: auto; }

/* =========================================
   Components
   ========================================= */

/* Content Wrapper */
.content {
  padding: 16px;
  margin-top: 25px;
  width: fit-content !important;
  min-width: min(100%, 320px);
  max-width: 100% !important;
  box-sizing: border-box;
}

/* Card */
.card, .card-md {
  background: var(--card-bg);
  border: var(--border-width) solid var(--border-color);
  border-radius: var(--border-radius-card) !important;
  padding: 1.5rem;
  box-shadow: var(--box-shadow);
  margin-bottom: 1rem;
  transition: all 0.3s ease;
  width: fit-content !important;
  min-width: 100%;
  max-width: 100% !important;
  box-sizing: border-box;
}
.card-md { max-width: 520px; margin: 2rem auto; }

/* Buttons */
/* Table & Small Buttons */
.done-btn, .btn-sm {
  padding: 0.3rem 0.6rem !important;
  font-size: 0.85rem !important;
  min-height: 28px !important;
}

button, .button, input[type=submit], .btn-primary, .btn-danger {
  -webkit-appearance: none;
  appearance: none;
  display: inline-block;
  background-color: var(--primary) !important;
  color: var(--on-primary) !important;
  text-align: center;
  padding: 0.8rem 1.2rem;
  border-radius: var(--border-radius-btn) !important;
  text-decoration: none;
  border: var(--border-width) solid var(--border-color);
  box-shadow: var(--btn-shadow);
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s ease, filter 0.2s ease, box-shadow 0.1s ease;
}
button:hover, .button:hover, input[type=submit]:hover, .btn-primary:hover, .btn-danger:hover {
  filter: brightness(0.9);
}
button:active, .button:active, input[type=submit]:active, .btn-primary:active, .btn-danger:active {
  transform: translate(2px, 2px);
  box-shadow: none;
}
button + button, .button + .button, input[type=submit] + input[type=submit] {
  margin-left: 1em;
}

.btn-secondary {
  background-color: transparent !important;
  border: max(1px, var(--border-width)) solid var(--border-color);
  color: var(--text) !important;
}
.btn-secondary:hover {
  background-color: rgba(0,0,0,0.05) !important;
}

/* Forms & Inputs */
input[type="text"], input[type="password"], input[type="date"], input[type="week"], input[type="month"], input[type="time"], input[type="number"], input[type="tel"], input[type="email"], select, textarea, .task_input {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  padding: 0.8rem;
  border: max(1px, var(--border-width)) solid var(--border-color);
  background-color: var(--card-bg);
  border-radius: var(--border-radius-input) !important;
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
  box-sizing: border-box;
  margin-bottom: 1rem;
  box-shadow: var(--btn-shadow);
  transition: border-radius 0.3s ease, border 0.3s ease, box-shadow 0.2s ease, transform 0.2s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--on-primary);
  box-shadow: 0 0 0 2px rgba(0,0,0,0.1);
}
select option {
  background-color: var(--card-bg);
  color: var(--text);
  padding: 0.5rem;
}
form.vstack > div > label {
  display: block;
  margin: 0 0 .4rem;
  font-weight: 600;
}
.checkboxes.row {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem 1rem;
}
.checkboxes.row .yn-inline {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
}

/* Tables */
.table, table { width: 100%; border-collapse: collapse; }
th, td { padding: 0.8rem; border-bottom: 1px solid var(--border-color); text-align: left; }
th { font-size: 0.9rem; font-weight: 700; color: var(--text-muted); }
.table-wrap { overflow: auto; }

/* Menu FAB (Floating Action Button) */
.menu-fab {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top));
  right: 12px;
  width: 48px; height: 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: var(--card-bg);
  border: var(--border-width) solid var(--border-color);
  border-radius: var(--border-radius-btn) !important;
  box-shadow: var(--btn-shadow);
  z-index: 1100;
  cursor: pointer;
  transition: all 0.2s ease;
  padding: 0;
  box-sizing: border-box;
  text-decoration: none;
  color: var(--text);
  outline: none;
}
.menu-fab:active {
  transform: translate(2px, 2px);
  box-shadow: none;
}
.menu-fab .menu-line {
  display: block;
  width: 22px; height: 2px;
  background: var(--text);
  border-radius: 2px;
}

/* Drawer */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  opacity: 0; transition: opacity 0.2s ease; pointer-events: none; z-index: 999;
}
.overlay.open { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed; inset: 0 auto 0 0; width: 280px; 
  background-color: var(--card-bg); color: var(--text);
  border-right: var(--border-width) solid var(--border-color);
  box-shadow: var(--box-shadow);
  transform: translateX(calc(-100% - 20px)); /* Push extra 20px to hide Neo-Brutalism shadow */
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
  z-index: 1000;
  display: flex; flex-direction: column;
}
.drawer.open { transform: translateX(0); }

.drawer-scroll { padding: 10px; }
.drawer-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.drawer-link {
  display: flex; align-items: center; width: 100%; box-sizing: border-box;
  padding: 12px 16px; text-decoration: none;
  background: transparent; color: var(--text); font-weight: bold; font-size: 0.95rem;
  border-radius: var(--border-radius-btn) !important; cursor: pointer;
  border: var(--border-width) solid transparent;
  transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.drawer-icon { margin-right: 12px; font-size: 1.2rem; }

/* Theme specific drawer styles */
[data-design="neo-brutalism"] .drawer-link:hover {
  background: var(--primary); color: var(--on-primary);
  border-color: var(--border-color);
  box-shadow: var(--btn-shadow);
  transform: translate(-2px, -2px);
}

[data-design="material-you"] .drawer-link {
  border-radius: 99px; /* Classic Material pill menus */
  border-width: 0;
}
[data-design="material-you"] .drawer-link:hover {
  background: rgba(var(--primary-rgb, 100, 100, 100), 0.1);
  color: var(--primary);
}

.drawer-divider {
  height: 1px; width: 100%; background: var(--border-color);
  margin: 4px 0; opacity: 0.3; border: none !important;
}

/* Modals */
.modal-overlay { z-index: 1200; }
.modal {
  position: fixed; inset: 50% auto auto 50%;
  transform: translate(-50%, -50%) scale(0.95);
  width: min(92vw, 560px);
  background: var(--card-bg);
  color: var(--text);
  border: var(--border-width) solid var(--border-color);
  border-radius: var(--border-radius-card) !important;
  box-shadow: var(--box-shadow);
  z-index: 1201;
  padding-bottom: .5rem;
  opacity: 0;
  pointer-events: none;
  transition: transform 0.2s ease, opacity 0.2s ease;
}
.modal.open { transform: translate(-50%, -50%) scale(1); opacity: 1; pointer-events: auto; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem; border-bottom: 1px solid var(--border-color);
}
.modal-title { margin: 0; font-size: 1.1rem; font-weight: 700; }
.modal-close { background: transparent; border: none; font-size: 1.5rem; cursor: pointer; line-height: 1; color: var(--text); }
.modal-body { padding: 1rem; white-space: pre-wrap; word-wrap: break-word; }
.modal-footer { padding: 1rem; display: flex; justify-content: flex-end; }

/* Notifications (Notif Drawer) */
.notif-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); opacity: 0; transition: opacity .2s ease; pointer-events: none; z-index: 1600; }
.notif-overlay[hidden] { display: none !important; }
.notif-overlay.open { opacity: 1; pointer-events: auto; }
.notif-drawer {
  position: fixed; inset: 0; width: 100%; height: 100dvh;
  background: var(--bg); color: var(--text);
  display: flex; flex-direction: column;
  padding-top: calc(env(safe-area-inset-top) + 8px);
  padding-bottom: env(safe-area-inset-bottom);
  transform: translateY(-8px); opacity: 0; pointer-events: none;
  transition: transform .2s ease, opacity .2s ease; z-index: 1601;
}
.notif-drawer[hidden] { display: none !important; }
.notif-drawer.open { transform: none; opacity: 1; pointer-events: auto; }
.notif-header { display: flex; align-items: center; padding: 1rem; border-bottom: 1px solid var(--border-color); }
.notif-title { margin: 0; flex: 1; text-align: center; font-weight: 700; }
.notif-close { background: transparent; border: none; font-size: 1.5rem; cursor: pointer; color: var(--text); }
.notif-body { flex: 1; overflow: auto; padding: 1rem; -webkit-overflow-scrolling: touch; }
.notif-item { border-top: 1px dashed var(--border-color); padding: 1rem 0; }
.notif-item:first-child { border-top: none; }
.notif-when { font-size: .85rem; color: var(--text-muted); margin-bottom: .25rem; }
.notif-subject { font-weight: 700; margin-bottom: .25rem; }
.notif-text { white-space: pre-wrap; word-wrap: break-word; }

/* Utility Classes (For replacing inline styles) */
.page-title { margin: 16px 12px 8px; font-size: 24px; font-weight: 800; }
.my-1 { margin-top: 0.5rem; margin-bottom: 0.5rem; }
.my-3 { margin-top: 1rem; margin-bottom: 1rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 0.75rem; }
.mt-3 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 1rem; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-danger { color: #d32f2f; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.85rem; }
.fw-bold { font-weight: 700; }
.d-none { display: none !important; }
.d-block { display: block; }
.list-unstyled { list-style: none; margin: 0; padding: 0; }
.lh-lg { line-height: 1.8; }
.vstack { display: flex; flex-direction: column; gap: 0.75rem; }
.row { display: flex; flex-direction: row; gap: 1rem; width: 100%; }



button, .btn-primary, .menu-link { -webkit-tap-highlight-color: transparent; }


/* Mobile Optimization */
@media (max-width: 768px) {
  :root { font-size: 14px; }
  body { padding: 0 4px 20px 4px; }
  .content { padding: 4px; margin-top: 10px; }
  .card { padding: 0.8rem; margin: 0 0 1rem 0; }
  .page-title { font-size: 1.3rem; margin: 10px 4px 10px; text-align: left; }
  .menu-fab { width: 44px; height: 44px; }

  /* Form Layout (Only in standard form fields) */
  .field { 
    display: flex;
    flex-direction: column !important; 
    align-items: stretch !important; 
    gap: 4px !important; 
  }
  .field label { margin-bottom: 4px; }
  .field input, .field select, .field .custom-select, .field textarea, 
  form.vstack > input, form.vstack > select, form.vstack > .custom-select, form.vstack > textarea { 
    width: 100% !important; 
    margin-bottom: 0.5rem; 
  }
  .field input[type="checkbox"], form.vstack > input[type="checkbox"],
  .field input[type="radio"], form.vstack > input[type="radio"],
  .checkboxes input[type="checkbox"] {
    width: auto !important;
  }
  
  /* Flex wrappers & Toolbars (Horizontal Scrolling instead of wrapping) */
  .filter-bar > div:first-child, .filter-bar > form > div:last-child, .actions, .action-bar, .editor-container > div {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important; /* Do not wrap */
    align-items: center !important;
    justify-content: flex-start;
    gap: 8px !important;
    
    /* Enable smooth horizontal scrolling */
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    
    /* Hide scrollbar visually for cleaner UI (optional but recommended for button bars) */
    scrollbar-width: none; /* Firefox */
  }
  .filter-bar > div:first-child::-webkit-scrollbar, .filter-bar > form > div:last-child::-webkit-scrollbar, .actions::-webkit-scrollbar, .action-bar::-webkit-scrollbar, .editor-container > div::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
  }
  
  /* Prevent buttons and inputs from shrinking when scrolling */
  .filter-bar > div:first-child > *, .filter-bar > form > div:last-child > *, .actions > *, .action-bar > *, .editor-container > div > * {
    flex-shrink: 0 !important;
  }
  
  .done-btn, .btn-sm { padding: 4px 10px !important; font-size: 0.8rem !important; min-height: 30px !important; }

  /* Buttons: Ensure touch height. */
  .actions button, .actions a.btn-primary, .actions a.btn-outline, .filter-bar > div:first-child button, .filter-bar > form > div:last-child button, .editor-container button {
    width: auto !important;
    flex: 0 1 auto;
    margin: 0 !important;
    min-height: 32px; /* Touch friendly height, but smaller */
    padding: 4px 12px !important;
    font-size: 0.85rem !important;
  }
  
  /* Inline selects and inputs in toolbars shouldn't stretch */
  .editor-container select, .editor-container input, .filter-bar select, .filter-bar input {
    width: auto !important;
    min-height: 32px;
    margin: 0 !important;
    font-size: 0.85rem !important;
  }
  
  /* Tables & Grids */
  .grid-wrap, .h-scroll-wrap {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    width: 100% !important;
    margin: 10px -4px !important;
    padding-bottom: 15px !important; /* Space for scrollbar */
    border-radius: 0 !important;
    border-left: none !important;
    border-right: none !important;
  }
  .grid-table {
    font-size: 0.85rem;
  }
  th, td { 
    font-size: 0.85rem; 
    padding: 0.4rem; 
  }
  /* Reduce sticky column width to leave space for scrolling columns */
  .sticky-col { 
    width: 90px !important; 
    min-width: 90px !important; 
    font-size: 0.8rem;
  }
  
  /* Drawer */
  .drawer { width: 85% !important; max-width: 320px; }
}

/* ========================================================
   Custom Premium Select UI
======================================================== */
.custom-select {
  position: relative;
  width: 100%;
}
.custom-select select {
  display: none !important;
}
.select-selected {
  background-color: var(--card-bg);
  border: max(1px, var(--border-width)) solid var(--border-color);
  border-radius: var(--border-radius-input) !important;
  padding: 0.8rem 1rem;
  color: var(--text);
  cursor: pointer;
  box-sizing: border-box;
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
  font-family: inherit;
  box-shadow: var(--btn-shadow);
}
.select-selected:after {
  content: "▼";
  font-size: 0.7rem;
  margin-left: 10px;
  opacity: 0.6;
  transition: transform 0.2s;
}
.select-selected.select-arrow-active {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0,0,0,0.1);
}
.select-selected.select-arrow-active:after {
  transform: rotate(180deg);
}

/* Theme overrides for Select container */
[data-design="neo-brutalism"] .select-selected {
  border: var(--border-width) solid var(--border-color);
  /* Uses global var(--btn-shadow) now */
}
[data-design="neo-brutalism"] .select-selected.select-arrow-active {
  box-shadow: none;
  transform: translate(4px, 4px);
}

.select-items {
  position: absolute;
  background-color: var(--card-bg);
  top: calc(100% + 8px);
  left: 0;
  min-width: 100%;
  width: fit-content;
  max-width: 85vw;
  z-index: 9999;
  border-radius: 12px;
  border: 1px solid rgba(0,0,0,0.1);
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  max-height: 220px;
  overflow-y: auto;
  opacity: 1;
  transition: opacity 0.2s, transform 0.2s;
  transform-origin: top;
}

/* Theme overrides for Select Menu */
[data-design="neo-brutalism"] .select-items {
  border: 3px solid var(--border-color);
  border-radius: 0;
  box-shadow: 6px 6px 0 var(--border-color);
}
[data-design="material-you"] .select-items {
  border-radius: 24px;
  border: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.select-items div {
  color: var(--text);
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid rgba(0,0,0,0.05);
  transition: background 0.1s;
  white-space: nowrap;
}
.select-items div:last-child {
  border-bottom: none;
  padding-bottom: 20px; /* Ensures the last item is easily selectable even on mobile */
}
.select-items div:hover, .same-as-selected {
  background-color: var(--primary);
  color: var(--on-primary);
}
.select-hide {
  display: none;
  opacity: 0;
  transform: scaleY(0.9);
}

/* Specific component overrides using CSS adjacent sibling selector */
.notify-select + .select-selected, .week-selector .select-selected {
  border-radius: var(--border-radius-btn) !important;
  padding: 0.6rem 1rem;
  font-weight: bold;
}
.time-sel + .select-selected {
  padding: 4px;
  border-radius: 4px;
  min-width: 50px;
}

.btn-danger {
  background-color: #d9534f !important;
  color: #fff !important;
}

/* ========================================================
   Promo Selection Modal Styles (Material You style list items)
======================================================== */
.promo-option-label {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-input);
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s, transform 0.1s;
  font-weight: 500;
  color: var(--text);
  box-sizing: border-box;
  width: 100%;
}
.promo-option-label:hover {
  background: var(--bg);
  border-color: var(--primary);
}
.promo-option-label:active {
  transform: scale(0.98);
}
.promo-option-label input[type="radio"],
.promo-option-label input[type="checkbox"] {
  margin: 0;
  width: 20px;
  height: 20px;
  cursor: pointer;
  accent-color: var(--on-primary);
}


/* ===== Table Auto-Scaling and Flex-Width Control ===== */
table, .grid-table {
  width: max-content !important;
  max-width: 100% !important;
  margin-left: auto;
  margin-right: auto;
}

/* Allow scrollable tables to expand beyond screen width inside scroll wrappers */
.grid-wrap table, 
.h-scroll-wrap table, 
.table-container table {
  max-width: none !important;
}


/* ===== Global Smartphone Landscape Optimization (スマホ横画面対応) ===== */
@media (max-height: 500px) and (orientation: landscape) {
  :root {
    font-size: 13px !important;
  }
  body {
    padding: 0 4px 10px 4px !important;
  }
  .content {
    margin-top: 10px !important;
    padding: 4px !important;
  }
  .card, .card-md {
    padding: 1rem !important;
    margin-bottom: 0.75rem !important;
    border-radius: min(16px, var(--border-radius-card)) !important;
  }
  .page-title {
    font-size: 1.4rem !important;
    margin: 8px 4px !important;
  }
  input[type="text"], input[type="password"], input[type="date"], input[type="week"], input[type="month"], input[type="time"], input[type="number"], input[type="tel"], input[type="email"], select, textarea, .task_input {
    padding: 0.5rem !important;
    margin-bottom: 0.6rem !important;
  }
  button, .button, input[type=submit], .btn-primary, .btn-danger {
    padding: 0.5rem 1rem !important;
  }
  th, td {
    padding: 0.5rem 0.4rem !important;
  }
  .menu-fab {
    width: 40px !important;
    height: 40px !important;
    top: 6px !important;
    right: 8px !important;
  }
}
