:root {
  --bg: #08111f;
  --panel: rgba(15, 27, 49, 0.86);
  --line: rgba(255, 255, 255, 0.09);
  --text: #f8fafc;
  --muted: #b4c1d4;
  --accent: #f59e0b;
  --accent-2: #38bdf8;
  --shadow: 0 24px 60px rgba(2, 6, 23, 0.42);
}

body {
  font-family: "Noto Sans JP", "Yu Gothic", "Hiragino Kaku Gothic ProN", sans-serif;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(56, 189, 248, 0.18), transparent 28%),
    radial-gradient(circle at top right, rgba(245, 158, 11, 0.12), transparent 30%),
    linear-gradient(180deg, #08111f 0%, #0b1324 100%);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: rgba(8, 17, 31, 0.92);
  color: var(--text);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.topbar a {
  color: var(--text);
  margin-left: 12px;
  text-decoration: none;
}

.logout-button {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  font: inherit;
  cursor: pointer;
}

.container {
  padding: 24px 24px 24px 36px;
}

.card,
.sheet,
.panel,
.student-card,
.messages .message,
.weekday-button,
.auth-card,
table {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.card {
  padding: 22px 24px 24px;
  margin-bottom: 18px;
}

.sheet {
  padding: 22px 24px 24px;
  margin-bottom: 18px;
}

.button {
  display: inline-block;
  padding: 10px 14px;
  background: linear-gradient(135deg, var(--accent), #fb7185);
  color: #08111f;
  border-radius: 10px;
  text-decoration: none;
  border: none;
}

.button.secondary {
  background: rgba(2, 6, 23, 0.34);
  color: var(--text);
  border: 1px solid var(--line);
}

.app-form {
  display: grid;
  gap: 16px;
  margin-top: 18px;
}

.app-form p {
  margin: 0;
  display: grid;
  gap: 8px;
}

.app-form label {
  font-weight: 700;
  color: var(--text);
}

.app-form input,
.app-form textarea,
.app-form select {
  width: 100%;
  box-sizing: border-box;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(2, 6, 23, 0.34);
  color: var(--text);
  font: inherit;
}

.app-form input:focus,
.app-form textarea:focus,
.app-form select:focus {
  outline: none;
  border-color: rgba(56, 189, 248, 0.75);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.18);
}

.app-form textarea {
  min-height: 140px;
  resize: vertical;
}

.app-form .helptext,
.app-form .errorlist {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.app-form .errorlist {
  color: #fca5a5;
  list-style: none;
  padding: 0;
}

.student-card {
  padding: 20px 22px 20px 24px;
  text-decoration: none;
  color: inherit;
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.page-head h2 {
  margin: 0;
}

.student-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.sheet-row {
  margin: 0 0 14px;
}

.sheet-row.two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.sheet-row .label {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.92rem;
}

.sheet-row .value {
  line-height: 1.7;
}

.sheet-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 8px 0 18px;
}

.panel {
  min-height: 120px;
  padding: 16px;
}

.student-detail-card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.student-detail-card h2 {
  margin-top: 0;
  margin-bottom: 14px;
}

.student-detail-card p {
  margin: 0;
  line-height: 1.7;
}

.student-typing-metrics {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.student-typing-metrics span {
  display: block;
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 4px;
}

.student-typing-metrics strong {
  font-size: 1.05rem;
}

.messages .message {
  padding: 10px 12px;
  margin-bottom: 8px;
}

.weekday-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 72px;
  padding: 12px 16px;
  border-radius: 999px;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
}

.weekday-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 18px 0 8px 4px;
}

.search-form {
  display: grid;
  gap: 12px;
  margin: 20px 0 12px;
  padding: 18px 18px 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(2, 6, 23, 0.28), rgba(2, 6, 23, 0.18));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.search-label {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.search-row {
  display: flex;
  gap: 12px;
  align-items: stretch;
}

.search-row input[type="search"] {
  flex: 1;
  min-width: 0;
  min-height: 56px;
  padding: 0 18px;
  background: rgba(2, 6, 23, 0.42);
  border-color: rgba(148, 163, 184, 0.22);
  border-radius: 999px;
  color: var(--text);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.search-row input[type="search"]::placeholder {
  color: rgba(180, 193, 212, 0.72);
}

.search-row input[type="search"]:focus {
  border-color: rgba(245, 158, 11, 0.7);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.03),
    0 0 0 3px rgba(245, 158, 11, 0.16);
}

.search-row .button {
  width: auto;
  min-width: 104px;
  min-height: 56px;
  padding: 0 22px;
  border-radius: 999px;
  font-weight: 700;
}

.weekday-button.active {
  background: linear-gradient(135deg, var(--accent), #fbbf24);
  color: #0b1324;
}

.text-button {
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
  color: var(--accent-2);
  font: inherit;
}

.portal-hero {
  padding: 32px 0 18px;
}

.hero-copy {
  max-width: 960px;
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
}

.lead {
  margin: 12px 0 0;
  color: var(--muted);
}

.portal-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 28px;
  margin-top: 28px;
}

.portal-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 240px;
  padding: 32px;
  text-decoration: none;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  transition: transform 0.18s ease, border-color 0.18s ease;
}

.portal-card:hover {
  transform: translateY(-3px);
  border-color: rgba(245, 158, 11, 0.45);
}

.portal-card.is-loading {
  pointer-events: none;
  cursor: wait;
  opacity: 0.82;
}

.portal-card h2 {
  margin: 0;
  font-size: 1.7rem;
}

.portal-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.portal-action {
  margin-top: auto;
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 18px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), #fbbf24);
  color: #0b1324;
  font-weight: 700;
  box-shadow: 0 12px 24px rgba(245, 158, 11, 0.2);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
}

a {
  color: inherit;
}

@media (max-width: 900px) {
  .portal-grid {
    grid-template-columns: 1fr;
  }

  .page-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .sheet-row.two-col {
    grid-template-columns: 1fr;
  }

  .student-detail-card-grid {
    grid-template-columns: 1fr;
  }

  .sheet-actions {
    flex-direction: column;
    align-items: flex-start;
  }

  .search-row {
    flex-direction: column;
  }

  .search-row .button {
    width: 100%;
  }

  .search-row input[type="search"] {
    min-height: 52px;
  }

    .search-row .button {
      min-height: 52px;
    }
}

.typing-shell {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.typing-shell-student {
  grid-template-columns: 220px minmax(0, 1fr);
}

.typing-sidebar {
  display: grid;
  gap: 12px;
  padding: 18px;
  background: rgba(7, 18, 38, 0.82);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  position: sticky;
  top: 20px;
}

.typing-sidebar-item {
  display: block;
  padding: 14px 16px;
  border-radius: 14px;
  color: var(--text);
  text-decoration: none;
  background: rgba(255, 255, 255, 0.03);
}

.typing-sidebar-item.active {
  background: linear-gradient(135deg, #2563eb, #3b82f6);
}

.typing-main {
  display: grid;
  gap: 20px;
}

.typing-page-head,
.typing-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.typing-page-head h1,
.typing-card h2,
.typing-card h3 {
  margin-bottom: 0;
}

.typing-card {
  padding: 24px;
  background: rgba(255, 255, 255, 0.95);
  color: #0f172a;
  border-radius: 24px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  box-shadow: 0 22px 50px rgba(2, 6, 23, 0.18);
}

.typing-card p,
.typing-card label,
.typing-card span {
  color: #475569;
}

.typing-card strong,
.typing-card h2,
.typing-card h3 {
  color: #0f172a;
}

.typing-card-header {
  margin-bottom: 18px;
}

.typing-form-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 18px;
  align-items: end;
}

.typing-field {
  display: grid;
  gap: 8px;
}

.typing-field label {
  font-weight: 700;
}

.typing-input,
.typing-select {
  width: 100%;
  min-height: 56px;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: #fff;
  color: #0f172a;
  box-sizing: border-box;
}

.typing-input[readonly] {
  background: #e2e8f0;
}

.typing-score-box {
  display: grid;
  gap: 8px;
  padding: 18px;
  border-radius: 20px;
  background: linear-gradient(180deg, #eff6ff, #e0f2fe);
  border: 1px solid rgba(96, 165, 250, 0.28);
  min-height: 120px;
}

.typing-score-label {
  font-weight: 700;
}

.typing-score-value {
  font-size: 2.5rem;
  font-weight: 900;
  color: #2563eb;
  line-height: 1;
}

.typing-score-note {
  font-size: 0.9rem;
}

.typing-form-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

.typing-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.typing-summary-panel {
  padding: 20px;
  border-radius: 20px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: linear-gradient(180deg, #fff, #f8fafc);
}

.typing-metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.typing-metric-card {
  padding: 16px;
  border-radius: 18px;
  background: rgba(248, 250, 252, 0.95);
  border: 1px solid rgba(148, 163, 184, 0.18);
}

.typing-metric-card span {
  display: block;
  margin-bottom: 8px;
  font-size: 0.92rem;
}

.typing-metric-card strong {
  font-size: 1.4rem;
}

.typing-trend-card {
  margin-top: 18px;
  padding: 20px;
  border-radius: 20px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: linear-gradient(180deg, #fff, #f8fafc);
}

.typing-chart {
  width: 100%;
  min-height: 260px;
  margin-top: 16px;
  border-radius: 20px;
  background:
    linear-gradient(to bottom, rgba(148, 163, 184, 0.14) 1px, transparent 1px) 0 0 / 100% 52px,
    #fff;
}

.typing-axis-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 14px;
  color: #64748b;
  font-size: 0.88rem;
  font-weight: 700;
}

.typing-chart-labels {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(52px, 1fr));
  gap: 8px;
  margin-top: 10px;
  color: #64748b;
  font-size: 0.88rem;
}

.typing-legend {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #475569;
  flex-wrap: wrap;
}

.typing-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 999px;
}

.typing-dot-blue {
  background: #2563eb;
}

.typing-dot-green {
  background: #16a34a;
}

.typing-dot-orange {
  background: #f59e0b;
}

.typing-student-name,
.typing-empty-note {
  margin-bottom: 16px;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(239, 246, 255, 0.95);
  color: #1e3a8a;
  border: 1px solid rgba(96, 165, 250, 0.22);
}

.typing-field .errorlist {
  list-style: none;
  padding: 0;
  margin: 0;
  color: #dc2626;
}

.typing-popup-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.58);
  backdrop-filter: blur(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 1000;
}

.typing-popup-overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.typing-popup-card {
  position: relative;
  width: min(92vw, 560px);
  padding: 24px;
  border-radius: 28px;
  background: linear-gradient(180deg, #ffffff, #f8fafc);
  box-shadow: 0 28px 70px rgba(15, 23, 42, 0.28);
  border: 1px solid rgba(148, 163, 184, 0.28);
  text-align: center;
  transform: translateY(16px) scale(0.96);
  transition: transform 0.24s ease;
}

.typing-popup-overlay.is-visible .typing-popup-card {
  transform: translateY(0) scale(1);
}

.typing-popup-card-loading {
  background: linear-gradient(180deg, #eff6ff, #ffffff);
}

.typing-popup-card-success {
  background: linear-gradient(180deg, #fffbea, #ffffff);
}

.typing-popup-image {
  display: block;
  width: min(100%, 420px);
  margin: 0 auto 16px;
  border-radius: 22px;
}

.typing-popup-title {
  margin: 0 0 10px;
  font-size: clamp(1.8rem, 4vw, 2.5rem);
  color: #b45309;
}

.typing-popup-caption {
  margin: 0;
  color: #475569;
  font-size: 1rem;
  line-height: 1.7;
}

.typing-popup-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.08);
  color: #0f172a;
  font-size: 1.4rem;
  cursor: pointer;
}

.typing-popup-close:hover {
  background: rgba(15, 23, 42, 0.14);
}

.auth-loading-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.58);
  backdrop-filter: blur(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 1000;
}

.auth-loading-overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.auth-loading-card {
  width: auto;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  text-align: center;
  transform: translateY(16px) scale(0.96);
  transition: transform 0.24s ease;
}

.auth-loading-overlay.is-visible .auth-loading-card {
  transform: translateY(0) scale(1);
}

.auth-loading-image {
  display: block;
  width: 400px;
  height: 300px;
  margin: 0 auto;
  max-width: 100%;
  border-radius: 10px;
  object-fit: cover;
  object-position: center;
}

#login-submit-button.is-loading,
#login-submit-button:disabled {
  cursor: wait;
  opacity: 0.82;
}

@media (max-width: 1100px) {
  .typing-shell,
  .typing-shell-student {
    grid-template-columns: 1fr;
  }

  .typing-sidebar {
    position: static;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  }

  .typing-form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .typing-page-head,
  .typing-section-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .typing-form-grid,
  .typing-summary-grid,
  .typing-metric-grid {
    grid-template-columns: 1fr;
  }

  .typing-card {
    padding: 18px;
  }

  .typing-popup-overlay {
    padding: 16px;
  }

  .typing-popup-card {
    padding: 18px;
    border-radius: 22px;
  }

  .typing-popup-close {
    top: 10px;
    right: 10px;
  }

  .auth-loading-overlay {
    padding: 16px;
  }

  .auth-loading-card {
    padding: 0;
    border-radius: 0;
  }

  .auth-loading-image {
    width: min(100%, 400px);
    height: min(calc((100vw - 32px) * 0.75), 300px);
  }
}
