:root {
  --primary: #1e3a8a;
  --accent: #2563eb;
  --bg: #f3f4f6;
  --border: #333333;
}
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0; padding: 0;
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Meiryo", sans-serif;
  background-color: var(--bg); color: #111;
}

.screen { display: none; }
.screen.active { display: block; }

.home-container { max-width: 600px; margin: 40px auto; padding: 20px; text-align: center; }
.home-hero {
  background: var(--primary); color: white; padding: 40px 20px; border-radius: 16px; margin-bottom: 30px;
  box-shadow: 0 4px 15px rgba(30,58,138,0.3);
}
.home-hero h1 { margin: 0 0 10px 0; font-size: 26px; }
.home-hero p { margin: 0; font-size: 14px; opacity: 0.9; }
.home-menu-grid { display: flex; flex-direction: column; gap: 16px; }
.home-card-btn {
  background: white; border: 2px solid #e5e7eb; border-radius: 12px; padding: 24px;
  display: flex; flex-direction: column; align-items: center; gap: 8px; cursor: pointer;
  transition: all 0.2s; box-shadow: 0 2px 8px rgba(0,0,0,0.05); text-align: center;
}
.home-card-btn:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0,0,0,0.1); }
.btn-create { border-left: 6px solid #10b981; }
.btn-search { border-left: 6px solid var(--accent); }
.home-icon { font-size: 32px; }
.home-title { font-size: 18px; font-weight: bold; color: #111; }
.home-desc { font-size: 13px; color: #6b7280; }

.search-filter-bar {
  background: white; padding: 12px 16px; border-bottom: 1px solid #e5e7eb;
  display: flex; gap: 10px; max-width: 800px; margin: 0 auto; box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}
.search-input {
  flex: 1; padding: 8px 12px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 14px; outline: none; background: #fff;
}
.tag-cloud-bar {
  max-width: 800px; margin: 10px auto; padding: 0 16px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
}
.filter-tag-chip {
  background: #e0e7ff; color: #1e40af; border: 1px solid #93c5fd; padding: 4px 10px; border-radius: 16px; font-size: 12px; font-weight: bold; cursor: pointer; transition: all 0.15s;
}
.filter-tag-chip.active { background: var(--accent); color: white; border-color: var(--accent); }
.search-results-container { max-width: 800px; margin: 16px auto; padding: 0 16px; }

.app-header {
  background: var(--primary); color: white;
  padding: 10px 14px; position: sticky; top: 0; z-index: 1000;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
}
.header-left, .header-right { display: flex; gap: 4px; align-items: center; }
.header-title-text { font-size: 14px; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 140px; }
.btn {
  background: white; color: var(--primary); border: none;
  padding: 6px 10px; border-radius: 6px; font-size: 11px;
  font-weight: bold; cursor: pointer; white-space: nowrap;
}
.btn-primary { background: #10b981; color: white; }
.btn-danger { background: #dc2626; color: white; }

.toolbar {
  background: #ffffff; border-bottom: 1px solid #d1d5db;
  padding: 8px; position: sticky; top: 53px; z-index: 999;
  display: flex; flex-wrap: wrap; gap: 6px; justify-content: center;
}
.tool-btn {
  border: 1px solid #d1d5db; background: #f9fafb;
  padding: 5px 9px; border-radius: 6px; font-size: 11px; cursor: pointer;
}
.tool-btn.active { background: var(--accent); color: white; border-color: var(--accent); font-weight: bold; }
.tool-eraser { background: #fee2e2; border-color: #f87171; color: #991b1b; }
.tool-eraser.active { background: #dc2626 !important; color: white !important; }
.dot-student { color: #1d4ed8; }
.dot-coach { color: #dc2626; font-weight: bold; }
.workspace { padding: 16px 12px; display: flex; justify-content: center; }

.sheet {
  background: white; width: 794px; max-width: 794px; min-width: 794px;
  padding: 30px 35px; box-shadow: 0 4px 12px rgba(0,0,0,0.1); border-radius: 4px;
  margin: 0 auto; box-sizing: border-box;
}
.sheet-title-wrap { border-bottom: 2px solid var(--border); padding-bottom: 6px; margin-bottom: 16px; text-align: center; }
.meta-inputs { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; }
.sheet-title-input {
  flex: 1; border: none; font-size: 18px; font-weight: bold;
  text-align: center; outline: none; font-family: inherit; background: transparent;
}
.menu-section {
  display: flex; flex-direction: row; gap: 20px;
  padding: 16px 0; border-bottom: 2px dashed #4b5563; align-items: flex-start;
  width: 100%; box-sizing: border-box; position: relative;
}
.menu-section:last-child { border-bottom: none; }
.court-column { flex: 0 0 180px; width: 180px; display: flex; flex-direction: column; align-items: center; }
.canvas-container {
  width: 180px; height: 260px; border: 2px solid #222;
  background: #ffffff; touch-action: none; position: relative;
}
canvas { display: block; width: 180px; height: 260px; cursor: crosshair; }
.court-controls { margin-top: 6px; display: flex; gap: 4px; justify-content: center; width: 100%; }
.mini-btn { font-size: 11px; padding: 3px 6px; border: 1px solid #9ca3af; background: #f3f4f6; border-radius: 4px; cursor: pointer; }

.text-column { flex: 1; width: 524px; max-width: 524px; display: flex; flex-direction: column; gap: 10px; box-sizing: border-box; overflow: hidden; }

.field-block { display: flex; flex-direction: column; gap: 3px; width: 100%; box-sizing: border-box; position: relative; }
.field-header-row { display: flex; justify-content: space-between; align-items: center; width: 100%; }
.field-label-input {
  font-size: 13px; font-weight: bold; border: none; background: transparent;
  width: 70%; font-family: inherit; outline: none; padding: 2px 0;
  color: #111; border-bottom: 1px dashed transparent; box-sizing: border-box;
}
.field-label-input:focus { border-bottom: 1px dashed var(--accent); background: #f8fafc; }

.lined-textarea {
  width: 100%; max-width: 100%; border: none; outline: none; resize: none;
  font-family: inherit; font-size: 13px; line-height: 26px;
  background-color: transparent;
  background-image: linear-gradient(transparent, transparent 25px, #d1d5db 25px, #d1d5db 26px);
  background-size: 100% 26px; padding: 0 4px; overflow-y: hidden; box-sizing: border-box;
  white-space: pre-wrap;
  word-break: break-all;
}
.lines-2 { height: 52px; }
.lines-5 { height: 130px; }

.tag-chip {
  background: #e0e7ff; color: #1e40af; padding: 4px 10px; border-radius: 12px; font-size: 12px; font-weight: bold; display: inline-flex; align-items: center; gap: 4px;
}
.tag-chip span { cursor: pointer; color: #dc2626; font-weight: bold; }

.lib-card {
  background: white; border: 1px solid #e5e7eb; border-radius: 8px; padding: 12px; margin-bottom: 8px;
  display: flex; justify-content: space-between; align-items: center; box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.lib-card-info { flex: 1; cursor: pointer; text-align: left; }
.lib-card-title { font-weight: bold; font-size: 15px; color: #1e3a8a; margin-bottom: 4px; }
.lib-card-meta { font-size: 12px; color: #6b7280; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.lib-tag { background: #e0e7ff; color: #1e40af; padding: 2px 6px; border-radius: 4px; font-weight: bold; }
.lib-card-actions { display: flex; gap: 6px; }

.zoom-modal {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.8); z-index: 2000; display: flex; justify-content: center; align-items: center; padding: 10px;
}
.zoom-content {
  background: white; border-radius: 12px; width: 100%; max-width: 500px; padding: 16px; display: flex; flex-direction: column; align-items: center; box-shadow: 0 10px 25px rgba(0,0,0,0.3);
}
.zoom-header { width: 100%; display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.zoom-header h2 { font-size: 15px; margin: 0; color: #1e3a8a; }

@media (max-width: 840px) {
  .workspace { overflow-x: auto; justify-content: flex-start; }
}
.court-controls { display: flex !important; }
@media print {
  .app-header, .toolbar, .court-controls { display: none !important; }
  body, .workspace { background: white; padding: 0; margin: 0; }
  .sheet { box-shadow: none; width: 100%; max-width: 100%; min-width: 0; padding: 5mm; }
  .menu-section { flex-direction: row !important; page-break-inside: avoid; }
  .canvas-container { border: none; }
}